Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWT transform coordinates to pixels



  • Hi,

    I duplicate my question from QtCenter because the problem wasn't solved yet.

    I'm going to use QLinearGradient to fill area between my_line and some baseline like on the second plot from here. To do this I need to know position of every point of my_line in pixels.
    QwtPlot::canvasMap(int axisId) says: Map for the axis on the canvas. With this map pixel coordinates can translated to plot coordinates and vice versa.
    I can't anderstand which one translate or invTranslate perform the rescaling from axes (x,y) coordinate units to pixels but I tried to use them both:

        QwtScaleMap xMap = ui->qwtPlot->canvasMap(QwtPlot::xBottom); // input parameter type is "axisid" is QwtPlot::yLeft correct?
        QwtScaleMap yMap = ui->qwtPlot->canvasMap(QwtPlot::yLeft);
    
        double x2 = xMap.transform(1000.0);
        double y2 = yMap.transform(1000.0);
    

    And I get the x2 and y2 numbers that are bigger than my QMainWindow size in QDesigner.

    By the way the QwtPlot widget in QDesigner has axes limits from 0 to 1000 and after I draw the curve the limits become about from 0 to 3. How to transform axes coordinates to pixels after I draw the curve?

    I'm working on that few days and all my ideas leaked out.


  • Lifetime Qt Champion

    Hi
    Qwt is not an official Qt Component so you might not get any answers here (if nobody uses it )
    and in that case, I would try the QWT mailing lists.



  • @mrjj you are right
    I tried to use mailing list yesterday but didnt understood how to do that :)
    After you wrote I found in Internet how to use mailing list and just created it
    Thank you :)


Log in to reply