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 achieve multiple tooltip on QGraphicsItem ?
Forum Updated to NodeBB v4.3 + New Features

How to achieve multiple tooltip on QGraphicsItem ?

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

    I want to set multiple tooltip on QGraphicsItem.
    Initially I will have name in tooltip.

    On Right mouse button I will have 1 option like "Enable attribute Info " When I will click that, on hover over QGraphicsItem , I should see attribute info.
    When that option will be disabled, on hover I should be able to see rectangle name.

    For that , in eventFilter() I have tried like this.

    case QEvent::MouseMove: {
            QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
            QPointF mousePoint = _view->mapToScene(mouseEvent->pos());
            QGraphicsItem* currentItem = _scene->itemAt(mousePoint, QTransform());
            myRect* rItem = dynamic_cast<myRect*>(currentItem);
            if(rItem){
            rItem->setToolTip(_attributeTableInfo);
            }
            break;
        }
    

    It is working properly. But issue is, once I set above tooltip my original tooltip of name is not there. I always get attribute info as a tooltip.

    I want attribute info tooltip, only when it is enable from Right mouse button, when it is disable I should get Name as tooltip.

    In short how to achieve, multiple tooltip ?

    mrjjM 1 Reply Last reply
    0
    • T tushu

      I want to set multiple tooltip on QGraphicsItem.
      Initially I will have name in tooltip.

      On Right mouse button I will have 1 option like "Enable attribute Info " When I will click that, on hover over QGraphicsItem , I should see attribute info.
      When that option will be disabled, on hover I should be able to see rectangle name.

      For that , in eventFilter() I have tried like this.

      case QEvent::MouseMove: {
              QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
              QPointF mousePoint = _view->mapToScene(mouseEvent->pos());
              QGraphicsItem* currentItem = _scene->itemAt(mousePoint, QTransform());
              myRect* rItem = dynamic_cast<myRect*>(currentItem);
              if(rItem){
              rItem->setToolTip(_attributeTableInfo);
              }
              break;
          }
      

      It is working properly. But issue is, once I set above tooltip my original tooltip of name is not there. I always get attribute info as a tooltip.

      I want attribute info tooltip, only when it is enable from Right mouse button, when it is disable I should get Name as tooltip.

      In short how to achieve, multiple tooltip ?

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @tushu
      Hi you would have to restore the tooltip if the user de-selected the "Enable attribute Info "

       if(rItem) {
             if (  EnableAttribInfo  )
                rItem->setToolTip(_attributeTableInfo);
            else
               rItem->setToolTip(_thenamesthing);
        }
      
      T 1 Reply Last reply
      4
      • mrjjM mrjj

        @tushu
        Hi you would have to restore the tooltip if the user de-selected the "Enable attribute Info "

         if(rItem) {
               if (  EnableAttribInfo  )
                  rItem->setToolTip(_attributeTableInfo);
              else
                 rItem->setToolTip(_thenamesthing);
          }
        
        T Offline
        T Offline
        tushu
        wrote on last edited by
        #3

        @mrjj
        Thanks. Your suggestion worked.

        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