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. Tooltip in a point of a graph
QtWS25 Last Chance

Tooltip in a point of a graph

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 810 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi, I want to put a toolTip in a point of a graph...I tried:

    double x_c = ui->widget->xAxis->coordToPixel(x_widg);
    double y_c = ui->widget->yAxis->coordToPixel(y_widg);
    QPoint coord;
    y_c = coord.y();
    x_c= coord.x();

              QToolTip::showText(coord, line9);
    

    x_widg and y_widg are the coordinates of the point...I tried this way but without solution..

    jsulmJ 1 Reply Last reply
    0
    • ? A Former User

      Hi, I want to put a toolTip in a point of a graph...I tried:

      double x_c = ui->widget->xAxis->coordToPixel(x_widg);
      double y_c = ui->widget->yAxis->coordToPixel(y_widg);
      QPoint coord;
      y_c = coord.y();
      x_c= coord.x();

                QToolTip::showText(coord, line9);
      

      x_widg and y_widg are the coordinates of the point...I tried this way but without solution..

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @vale88 said in Tooltip in a point of a graph:

      QPoint coord;
      y_c = coord.y();
      x_c= coord.x();

      These two lines are completely useless because https://doc.qt.io/qt-5/qpoint.html#QPoint, so you set x_c, y_c and coord to 0.
      It should actually be

      double x_c = ui->widget->xAxis->coordToPixel(x_widg);
      double y_c = ui->widget->yAxis->coordToPixel(y_widg);
      QPoint coord(x_c,  y_c);
      QToolTip::showText(coord, line9);
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      ? 1 Reply Last reply
      4
      • jsulmJ jsulm

        @vale88 said in Tooltip in a point of a graph:

        QPoint coord;
        y_c = coord.y();
        x_c= coord.x();

        These two lines are completely useless because https://doc.qt.io/qt-5/qpoint.html#QPoint, so you set x_c, y_c and coord to 0.
        It should actually be

        double x_c = ui->widget->xAxis->coordToPixel(x_widg);
        double y_c = ui->widget->yAxis->coordToPixel(y_widg);
        QPoint coord(x_c,  y_c);
        QToolTip::showText(coord, line9);
        
        ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        @jsulm There are two problems..when I have two screens and I put the graph on the second screen the tip is on the first screen..and when I click and the tip compares I have a refresh..a black shadow..anyway thanks for the help

        1 Reply Last reply
        0
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          Are you looking for something like this? https://doc.qt.io/qt-5/qtcharts-callout-example.html

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          ? 1 Reply Last reply
          0
          • VRoninV VRonin

            Are you looking for something like this? https://doc.qt.io/qt-5/qtcharts-callout-example.html

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @VRonin I wrote

            QPoint coord(ui->widget->mapToGlobal(QPoint(x_widg,y_widg)));
            QToolTip::showText(coord,line9);
            ui->widget_2->graph(4)->setData(qv_x2,qv_y2);

            but I obtain the point (0,0) on the MainWindow

            jsulmJ 1 Reply Last reply
            0
            • ? A Former User

              @VRonin I wrote

              QPoint coord(ui->widget->mapToGlobal(QPoint(x_widg,y_widg)));
              QToolTip::showText(coord,line9);
              ui->widget_2->graph(4)->setData(qv_x2,qv_y2);

              but I obtain the point (0,0) on the MainWindow

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @vale88 said in Tooltip in a point of a graph:

              x_widg,y_widg

              what values do they have and how did you get them?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              ? 1 Reply Last reply
              0
              • jsulmJ jsulm

                @vale88 said in Tooltip in a point of a graph:

                x_widg,y_widg

                what values do they have and how did you get them?

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                @jsulm x_widg and y_widg are right on the graph..then I havo to obtain this coordinates on the MainWindow to be global..but in this way the tip is on the top left of the screen and not on the coordinates (x_widg, y_widg)

                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