Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to set tooltip for only QIcon which is inside QTreeWidgetIteam?
Forum Updated to NodeBB v4.3 + New Features

How to set tooltip for only QIcon which is inside QTreeWidgetIteam?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 534 Views
  • 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.
  • B Offline
    B Offline
    bhvn
    wrote on last edited by
    #1

    In QTreeWidgetIteam have two different elements. QIcon and QLebel.
    If we set the tool tip like below, then it will give the tooltip to the entire cell of QTreeWidgetIteam.

    pTreeWidgetItem->setToolTip(ColNum, "Tooltip Text");
    

    I have to set the tooltip only on the Icon inside QTreeWidgetIteam.
    How to achieve this?

    Let me know If there is any query on this question.

    JonBJ 1 Reply Last reply
    0
    • B bhvn

      In QTreeWidgetIteam have two different elements. QIcon and QLebel.
      If we set the tool tip like below, then it will give the tooltip to the entire cell of QTreeWidgetIteam.

      pTreeWidgetItem->setToolTip(ColNum, "Tooltip Text");
      

      I have to set the tooltip only on the Icon inside QTreeWidgetIteam.
      How to achieve this?

      Let me know If there is any query on this question.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @bhvn
      Hello and welcome.

      I think this will be tricky, no easy way to do it. I can only see overriding the whole QTreeWidget's event(QEvent *event) and doing your own calculations for the mouse position to decide whether to show or ignore. See https://doc.qt.io/qt-6/qtwidgets-widgets-tooltips-example.html for inspiration. But I don't think you can even discover the icon's position.

      Meanwhile, I do not understand

      In QTreeWidgetIteam have two different elements. QIcon and QLebel.

      QTreeWidgetItems do not have widgets like QIcon or QLabel, maybe you are using QTreeWidget::setItemWidget(). You do not explain. But in such a case can't you set the tooltip on whatever widget you are placing there if you only want it to apply to that widget?

      B 1 Reply Last reply
      2
      • JonBJ JonB

        @bhvn
        Hello and welcome.

        I think this will be tricky, no easy way to do it. I can only see overriding the whole QTreeWidget's event(QEvent *event) and doing your own calculations for the mouse position to decide whether to show or ignore. See https://doc.qt.io/qt-6/qtwidgets-widgets-tooltips-example.html for inspiration. But I don't think you can even discover the icon's position.

        Meanwhile, I do not understand

        In QTreeWidgetIteam have two different elements. QIcon and QLebel.

        QTreeWidgetItems do not have widgets like QIcon or QLabel, maybe you are using QTreeWidget::setItemWidget(). You do not explain. But in such a case can't you set the tooltip on whatever widget you are placing there if you only want it to apply to that widget?

        B Offline
        B Offline
        bhvn
        wrote on last edited by
        #3

        @JonB
        I'm using for ICON qTreeWidgetItems->setIcon(COLUMN_NO, QIcon(statusIconRes)); And for text I'm are using
        qTreeWidgetItems->setData();

        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 Extensions
        • Unsolved