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.
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
Re: Where to start on a graphical "tooltip"
Quote:
Originally Posted by
SixDegrees
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.
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.