Results 1 to 8 of 8

Thread: Tooltips & Qt4 tree views

  1. #1
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs up Tooltips & Qt4 tree views

    Hi

    I've looked everywhere in the documentation but not found any hint about setting tooltips for QTreeView in an intelliigent way (like Qt3's QListView i.e. tooltips are displayed when item are not shown at once).

    How can i do that in Qt4?

    Thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltips & Qt4 tree views

    Make your model return the tooltip text of each of the items for the Qt::ToolTipRole role.

  3. #3
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Tooltips & Qt4 tree views

    Quote Originally Posted by wysota
    Make your model return the tooltip text of each of the items for the Qt::ToolTipRole role.
    I know that. But then the tooltips are always shown not when the contents are not shown entirely.

    Am i clear?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltips & Qt4 tree views

    I don't quite understand. Can you provide an example or somewhat broader explanation?

    If I understand, you want to show the tooltip only if a column is too narrow for the whole text of the item to fit in it?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltips & Qt4 tree views

    If you want to change the way the view displays the tooltip, you'll have to handle QAbstractItemView::viewportEvent().

  6. #6
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Tooltips & Qt4 tree views

    Quote Originally Posted by wysota
    If I understand, you want to show the tooltip only if a column is too narrow for the whole text of the item to fit in it?
    Yes. This is what i want and Qt3's QListView does that by default.
    Quote Originally Posted by wysota
    If you want to change the way the view displays the tooltip, you'll have to handle QAbstractItemView::viewportEvent().
    I think this should be the default behaviour. What do you say?

    Thanks for your patience

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltips & Qt4 tree views

    Quote Originally Posted by yogeshm02
    I think this should be the default behaviour. What do you say?
    No, this shouldn't be a default behaviour. Why? If an item has a tooltip, it is the tooltip that is displayed and not the item name. It sounds very sane to me.

  8. #8
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Tooltips & Qt4 tree views

    Quote Originally Posted by wysota
    No, this shouldn't be a default behaviour. Why? If an item has a tooltip, it is the tooltip that is displayed and not the item name. It sounds very sane to me.
    Agreed with above. But i wanted that behaviour if no tooltip was specified. I'll inherit from QTreeView and see if i can do what i want and if i am successful then i will post here. Bye till then.

    Thanks

Similar Threads

  1. how to disable views from a model
    By zeeeend in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2008, 21:14
  2. creating a Tree
    By mickey in forum General Programming
    Replies: 0
    Last Post: 20th April 2008, 17:57
  3. Optimizing filterAcceptsRow() to filter a tree
    By vfernandez in forum Qt Programming
    Replies: 1
    Last Post: 4th January 2007, 12:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.