Results 1 to 4 of 4

Thread: Where to start on a graphical "tooltip"

  1. #1
    Join Date
    Jan 2009
    Posts
    34
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Where to start on a graphical "tooltip"

    My users want a graphical representation instead of a tooltip, i.e. a tooltip-looking hovering rectangle that shows the detailed information of a node as a graphical representation.

    I have looked into the sourcecode of qtooltip.cpp and was thinking of making a similar class. As QToolTip is tailored to create a QLabel that shows text, I plan to subclass QGraphicsView and show this as a hovering rectangle with no frame-fluff.

    Is that the right class to start with? Any other tips? Any other baseclass that is better for this purpose?

    And I noticed that QToolTip have a separate internal singleton class QTipLabel. Is that really necessary? Shouldn't my class be able to make an instance of itself if necessary? Or is it much cleaner to maybe not subclass the access class, but rather subclass the extra singleton class from QGraphicsView (or some other class)?

    I plan to have the same type of static function GraphicalTooltip::showGraphicalTooltip(Node*, Widget*) to ease the use.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Where to start on a graphical "tooltip"

    QGraphicsView might be a bit heavyweight for something like this. You're able to display an image in a QLabel; I'd consider that approach first.

    As far as singletons go, I'm no fan of them. However, there can only be one tooltip visible at any given time, which was probably the designer's reason for selecting a singleton

  3. #3
    Join Date
    Jan 2009
    Posts
    34
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Where to start on a graphical "tooltip"

    Quote Originally Posted by SixDegrees View Post
    QGraphicsView might be a bit heavyweight for something like this. You're able to display an image in a QLabel; I'd consider that approach first.
    But I'm displaying a QGraphicsItem. I will also want to update the graphics if this tool stays up to show the updated data.

    And as for singleton, I came to the same conclusion. I would only allow one tooltip at a time and it should rather be updated with the current item's graphics.

  4. #4
    Join Date
    Jan 2009
    Posts
    34
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Where to start on a graphical "tooltip"

    I went for the subclassing of QGraphicsView and it works like a charm. I made a singleton of it so only one would be visible and would check the placement when a new request to show the tooltip was made. I could then reuse the tooltip (for the same tool or if they would overlap) and would make a new when necessary.

Similar Threads

  1. Phonon slow "start"
    By Talei in forum Newbie
    Replies: 0
    Last Post: 17th August 2010, 00:33
  2. qt preview "tooltip"
    By gycdavsys in forum Newbie
    Replies: 1
    Last Post: 1st February 2010, 10:56
  3. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  4. Replies: 2
    Last Post: 20th November 2007, 20:00
  5. Can I edit a two - rows "start" menu like XP ?
    By bigbigmoon in forum Newbie
    Replies: 2
    Last Post: 11th September 2006, 01:43

Tags for this Thread

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.