Results 1 to 5 of 5

Thread: Creating a Tooltip-like widget for mouse-hover of QListView items

  1. #1
    Join Date
    Sep 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Creating a Tooltip-like widget for mouse-hover of QListView items

    Hello.

    I have a QListView in which I have arranged the items of an item model in a grid (using the icons from each item's Qt:ecorationRole).

    What I would like to do now is to create an effect whereby, when the user hovers the mouse over one of the items in this grid - after a given delay - a box containing information about the hovered item is displayed somewhere near the cursor.

    The box can not be constrained by the size of the viewport.

    The problem is that I am not very sure where to begin. As far as I understand delegates, they seem insufficient for achieving this. Regular tooltips even more so (since their content's layout is fairly fixed).

    Would this be a matter of creating a QWidget-subclass (layed out in whatever way I need) with certain window flags somewhere in my QListView subclass after the firing of a timer after a hover has been detected?

    Any ideas?

    Thanks in advance.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Creating a Tooltip-like widget for mouse-hover of QListView items

    Why is Qt::ToolTipRole not suitable?

  3. #3
    Join Date
    Sep 2010
    Posts
    14
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a Tooltip-like widget for mouse-hover of QListView items

    I'm sure Qt::ToolTipRole is perfectly suitable.

    I was wondering more about the mechanics of how to temporarily display such an 'overlay' above the window containing my view.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Creating a Tooltip-like widget for mouse-hover of QListView items

    You simply return a QString containing the tooltip text. Qt will take care of displaying it.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Creating a Tooltip-like widget for mouse-hover of QListView items

    You can have some control over the display style of the standard tool tip text using style sheets attached to QToolTip.

Similar Threads

  1. Display widget as items in a QListView
    By remy_david in forum Qt Programming
    Replies: 0
    Last Post: 10th January 2011, 10:23
  2. add custom widget items to QListView or QListWidget
    By yazwas in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2010, 22:36
  3. Hover on mouse over while dragging
    By mooreaa in forum Qt Programming
    Replies: 3
    Last Post: 6th February 2010, 10:31
  4. segmentation fault on mouse hover
    By elessaar in forum Qt Programming
    Replies: 6
    Last Post: 26th August 2008, 12:51
  5. Hover and Highlight QTable and QTree Items
    By VireX in forum Qt Programming
    Replies: 41
    Last Post: 18th May 2007, 21:55

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.