[Qt-interest] Tree Item High Lighter

Sajjad dosto.walla at gmail.com
Mon Dec 27 21:46:08 CET 2010


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/b81e0988/attachment.html 


More information about the Qt-interest-old mailing list