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 position of tooltip for qlabel?

How to set position of tooltip for qlabel?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.0k 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.
  • G Offline
    G Offline
    guru
    wrote on last edited by
    #1

    Is it possible to set position of QTooltip at particular point of Dialog Screen in runtime, and display tooltip in left side?

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi,

      "In the tooltips example ":http://qt-project.org/doc/qt-5.0/qtwidgets/widgets-tooltips.html

      You can set how to set/get positions.

      bq. QWidget::event() is the main event handler and receives all the widget's events. Normally, we recommend reimplementing one of the specialized event handlers instead of this function. But here we want to catch the QEvent::ToolTip events, and since these are rather rare, there exists no specific event handler. For that reason we reimplement the main event handler, and the first thing we need to do is to determine the event's type:

      @
      if (event->type() == QEvent::ToolTip) {
      QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event);
      int index = itemAt(helpEvent->pos());
      if (index != -1) {
      QToolTip::showText(helpEvent->globalPos(), shapeItems[index].toolTip());
      } else {
      QToolTip::hideText();
      event->ignore();
      }

          return true;
      }
      return QWidget::event(event);
      

      }
      @

      bq. If the type is QEvent::ToolTip, we cast the event to a QHelpEvent, otherwise we propagate the event using the QWidget::event() function.

      hope it helps.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guru
        wrote on last edited by
        #3

        I doen'y understand position from that event handler, I just need to display tooltips in x,y position of screen. please specify meaning of @ QToolTip::showText(helpEvent->globalPos(), shapeItems[index].toolTip());@

        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