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. mouse tracer CustomPlot
Qt 6.11 is out! See what's new in the release blog

mouse tracer CustomPlot

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.7k 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

    I must build a mouseTracer like this:
    https://www.youtube.com/watch?v=BzK1DmJPbuk

    my problem it's that my marker follows the graph jerky..i built the graph with a vector x of double numbers and a vector y of randon numbers and I wrote:

    double x = (ui->Grafico->positionX);
    int j;
    double u;
    for (int i=0; i<1000; i++)
    {
    if (abs(xalt[i] - x)<0.1)
    {
    u= xalt[i];
    j=i;

       }
    

    }

    ui->Grafico->positionY = f_altezza[j];
    /QString h= QString::number(x);
    QString a = QString::number(f_altezza[x])
    /

    /*qDebug()<<"x"<<h<<endl;
    qDebug()<<"funz"<<a<<endl;
    qDebug()<<"funz1"<<f_altezza[33]*/
    

    if((ui->Grafico->mouseMarkerX) && (ui->Grafico->mouseMarkerY))
    {
    ui->Grafico->mouseMarkerX->point1->setCoords(ui->Grafico_Altezza_LdC_Acquisizione->positionX, 0);//VERTICALE
    ui->Grafico->mouseMarkerX->point2->setCoords(ui->Grafico_Altezza_LdC_Acquisizione->positionX, 1);//VERTICALE
    ui->Grafico->mouseMarkerY->point1->setCoords(0, ui->Grafico->positionY);//ORIZZONTALE
    ui->Grafico->mouseMarkerY->point2->setCoords(1, ui->Grafico->positionY);//ORIZZONTALE
    }
    ui->Grafico->replot();

    1 Reply Last reply
    0
    • mrjjM mrjj

      @vale88
      Sorry, i have no idea about that as i dont know the class you used or what you are
      actually doing with it.
      However, to follow the graph data on Y,
      i would assume you would ask the Plotter what y is from an x value.

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

      @mrjj I solved

      mrjjM 1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi
        If you call this in mouseMove and
        execute the 1000 loop each time, it might be the reason for it being jerky.

        ? 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          If you call this in mouseMove and
          execute the 1000 loop each time, it might be the reason for it being jerky.

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

          @mrjj so how I must do to obtain like in the video

          mrjjM 1 Reply Last reply
          0
          • ? A Former User

            @mrjj so how I must do to obtain like in the video

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

            @vale88
            Sorry, i have no idea about that as i dont know the class you used or what you are
            actually doing with it.
            However, to follow the graph data on Y,
            i would assume you would ask the Plotter what y is from an x value.

            ? 1 Reply Last reply
            0
            • mrjjM mrjj

              @vale88
              Sorry, i have no idea about that as i dont know the class you used or what you are
              actually doing with it.
              However, to follow the graph data on Y,
              i would assume you would ask the Plotter what y is from an x value.

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

              @mrjj I solved

              mrjjM 1 Reply Last reply
              1
              • ? A Former User

                @mrjj I solved

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

                @vale88
                Super :)
                Could you show how you did, so future readers might benefit ?

                ? 1 Reply Last reply
                0
                • mrjjM mrjj

                  @vale88
                  Super :)
                  Could you show how you did, so future readers might benefit ?

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

                  @mrjj

                  void MainWindow::Tracer_Acq()

                  {

                  double x = (Grafico->positionX);
                  int j;
                  double u;
                  double posX;
                  
                  
                  QString h = QString::number(x,'f',2);
                  double x1 = h.toDouble();
                  for (int i=0; i<1000; i++)
                  {
                      if  (abs(xalt[i] - x1) <0.001)
                      {
                  
                         u= xalt[i];
                         j=i;
                  
                         Grafico->positionY = f_altezza[j];
                         posX = xalt[j];
                         if((Grafico->mouseMarkerX) && (Grafico->mouseMarkerY))
                  
                         {
                            Grafico->mouseMarkerX->point1->setCoords(Grafico->positionX, 0);//VERTICALE
                            Grafico->mouseMarkerX->point2->setCoords(Grafico->positionX, 1);//VERTICALE
                            Grafico->mouseMarkerY->point1->setCoords(0,Altezza_acq_bis->positionY);//ORIZZONTALE
                            Grafico->mouseMarkerY->point2->setCoords(1, Grafico->positionY);//ORIZZONTALE
                  
                  
                            QString x_text = QString::number(Grafico->positionX,'f',2);
                            QString y_text = QString::number(Grafico->positionY);
                  
                            QString coord_p = QString("%1, %2").arg(x_text,y_text);
                            QCursor cursor;
                            QToolTip::showText(cursor.pos(),coord_p,this,QRect(),2000);
                  
                         }}
                  
                  
                      }
                        Grafico->replot();
                   }
                  

                  it isn't completely solved but better I don't know if it's possible

                  1 Reply Last reply
                  1

                  • Login

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