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. qcustomplot: pixelsToCoords
Qt 6.11 is out! See what's new in the release blog

qcustomplot: pixelsToCoords

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 351 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.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by sitesv
    #1

    Hi!

    QVector<double> x;
    for(int i = 0; i < 128; i++){
         x.push_back(i);
    }
    double scale = 2000;
    for(int i = -64; i < 64; i++){
        x[i+64] = scale/128*i;
    }
    ui->graph->xAxis->setRange(-0.5*scale, 0.5*scale);
    

    I use mouse click event.

    double px, py;
    ui->graph->graph(0)->pixelsToCoords(event->pos(), px, py);
    

    But I recieve 'px' in scaled values.
    How to convert it to QVector data index? In my case value should be between 0 and 127.

    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