[Qt-interest] Tree Item High Lighter

Scott Aron Bloom Scott.Bloom at onshorecs.com
Mon Dec 27 23:29:07 CET 2010


Filtering != highlighting.. But you can look at the implementation and learn how to highlight what you want

 

 

From: qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com [mailto:qt-interest-bounces+scott.bloom=onshorecs.com at qt.nokia.com] On Behalf Of Sajjad
Sent: Monday, December 27, 2010 12:46 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Tree Item High Lighter

 

 

On Mon, Dec 27, 2010 at 9:09 AM, André Somers <andre at familiesomers.nl> wrote:

I would look into QSortFilterProxyModel instead. You don't have to change your base tree model at all that way. Of course, if your underlying data store supports efficient searching (based on indexes for instance), then it would be better to implement the capability in your base model.

Note that by default, the proxy model only filters based on the root nodes. It is possible to customize it so it will include a node if one of it's child nodes match, but that requires some coding and will require an (almost) complete traversal of your tree. That makes it slow on big trees.

 

 

Is filtration and highlighting the same thing. I have going through some of the example and it shows that the the new filtered model based on the regular expression gets shrinked in the view. I do not want to alter the tree view except scrolling down to  the particular item and highlight a particular item that matches the nearest expression.

 

 

And the underlying data store does not support anything like what i  am looking for. I have to implement in Qt. Do i have to implement this searching technique in the custimized   QAbstractItemModel class? 

 

While loading the database in the tree model i followed the example of simple tree model example in Qt Demo. If i have to implement this scenario in simple tree model, which class do i have to look into and specially which functions?

 

 

Thanks

Sajjad

	
	André
	
	Op 27 dec. 2010 om 04:52 heeft Eckhard Jokisch <e.jokisch at orange-moon.de> het volgende geschreven:

	
	> Am 27.12.2010 00:54, schrieb Sajjad:
	>> Hello forum,
	>>
	>> I have subclassed the QAbstractItemModel to generate a customized tree model
	>> and since the tree model represent a large database, it is hard for the user
	>> to browse down all  the items in the  tree and find a  particular item. For
	>> a better usability, i would like to have a textfield where the user type a
	>> item name and the item with the name matched will be highlighted in the
	>> tree.
	>>
	>> Any hint on implementing this feature. I think i need to work with regular
	>> expression here and i am not sure how to search down the tree and highlight
	>> it.
	> What about this:
	> while setting up the model data also fill a QHash<QString,QModelIndex>.
	> Like this you can simply search for the string in the QHash and get the
	> associated modelindex.
	>
	> Have fun
	>
	> Eckhard
	>
	>>
	>> If there is already any example implementing this feature, please forward me
	>> to this.
	>>
	>>
	>> Any suggestion on implementing this feature would be very helpful.
	>>
	>>
	>> Happy New Year
	>>
	>> Sajjad
	>>
	>>
	>>
	>>
	>> _______________________________________________
	>> Qt-interest mailing list
	>> Qt-interest at qt.nokia.com
	>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
	>
	> _______________________________________________
	> Qt-interest mailing list
	> Qt-interest at qt.nokia.com
	> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
	_______________________________________________
	Qt-interest mailing list
	Qt-interest at qt.nokia.com
	http://lists.qt.nokia.com/mailman/listinfo/qt-interest

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101227/6c78a1cc/attachment.html 


More information about the Qt-interest-old mailing list