You are not logged in.

1

Thursday, August 27th 2009, 9:14pm

Implement a search widget for an address book

[QT] I am trying to implement a search widget for an addressbook

The address book consists of patient first and last name, phone number and address in a TABLE.

The address book is a table which consists of First Name, Last Name, Phone number, Address.

The search field (QLineEdit) takes in an input which filters the address book (if the search text string is present in the first/last name or phone number NOT in the address)

If any result contains the search string, the search string in the result will be highlighted Eg: If we search for 'a' and we have a first name Mark - 'a' in the name Mark will be in blue color

My current implementation uses a model/view design. I write my own model derived from QAbstractItemModel and view derived from QTableView. I plan to write my own delegate class inheriting from QItemDelegate for marking the highlighted text. The delegate adds QTextBrowser widgets for each field that contains highlighting (blue color) since QTextBrowser. For marking the text in different color I plan to use QSyntaxHighlighter.

The problem I am facing with this design is that since the QTextBrowser is painted on top of the widget, when a cell in my table is selected, the selection highlighting is not shown on my QTextBrowser. I was wondering if there is any better way to tackle this entire design to make it simplified.

Any inputs will be appreciated. :)

Similar threads

Rate this thread