Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [ENDED]set tooltip on an icon
Qt 6.12 LTS is out! See what's new in the release blog

[ENDED]set tooltip on an icon

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 5.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,

    I'm currently working on a QTableWidget.
    Some of the QTableWidgetItems have an icon ( with the function setICon ) that indicate the type of item.(some items represent a desk, some other chairs... etc)
    The icon could be not obvious enough for some users so I would like to set a tooltip on it that also say what type it is. (for example display "chair" as tooltip ont the icon of the chair)
    I can't find a way to do it.
    I also don't want to set the tooltip to the entire item, just on the icon.

    Thanks

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Does "QTableWidgetItem::setToolTip() ":http://doc.qt.nokia.com/4.7/qtablewidgetitem.html#setToolTip do the trick?

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Nope that's what I meant by my last sentance.
        I want to use the tooltip of the rest of the QTableWidgetItem for another contextual help.
        I need another tooltip that appears when the cursor is specificaly on the icon.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          I over-read that, sorry. And I'm sorry again - there is no builtin solution for your problem, the tooltip is for the whole item.

          To achieve this, I would switch from the QTableWidget to QTableView, create a model, add a custom role to that one (IconToolTipRole). One would probably have to subclass the table view and reimplement viewportEvent (see the implementation of "QAbstractItemView::viewportEvent() ":http://doc.qt.nokia.com/4.7/qabstractitemview.html#viewportEvent, it handles the tool tip request) to get the actual position of the mouse pointer.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Thnaks for the advices Volker.
            Anyway, I'll stick with QTableWidget and will change all the presentation because QGraphicsViews messes with my head. I'm not experimented enough to work with it.

            Thanks

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt
            • Unsolved