[Qt-interest] Using Qt delegate to render list of icons with tooltips?
Sean Harmer
sean.harmer at maps-technology.com
Mon Oct 26 14:17:46 CET 2009
Hi,
On Monday 26 Oct 2009 13:09:37 Thomi Richards wrote:
> I need to render a horizontal list of pixmaps in a QTableView. In
> itself that looks relatively simple using a custom delegate. However,
> I need each one of these pixmaps to have a different tooltop attached
> to it, such that the tooltip appears when the mouse hovers over the
> individual icon.
>
> I can't see a way to do that with the Qt delegate system - I can draw
> the pixmaps, but I can't see any way to associate the tooltip text
> with the pixmap, or any way to get notification when the tooltip needs
> to be drawn.
>
> is there a way to do this? Is it possible with the default item
> delegate, or should I be looking at something a bit more
> sophisticated?
Is each icon in it's own cell? ie Is there a one to one mapping between icons
and QModelIndex's? If so you can simply return a value for the Qt::ToolTipRole
role in your model's data() function. You should also be able to provide your
icons in the same way but using the Qt::DecorationRole. In this way you can
use the standard delegate.
If you have several icons and tool tips for any particular QModelIndex then
you will need to provide a custom delegate.
HTH,
Sean
More information about the Qt-interest-old
mailing list