Results 1 to 2 of 2

Thread: Convert canvas coordinates to parent widget

  1. #1
    Join Date
    Mar 2019
    Qt products

    Default Convert canvas coordinates to parent widget

    Hello everyone!

    Currently, I am facing a problem that I have a certain point on my canvas and I also have a parent widget that incorporates the whole plot. What I need to do is to convert a point from a curve in my canvas to coordinates relative to my parent widget.

    Does anybody know how I can do it?

    I tried doing the following example, but was not successful:

    auto points1 = plot_->canvas()->mapFromParent(pointsToConvert);
    auto points2= plot_->mapFromParent(points1 );
    auto points3 = mapFromParent(points2);

    Thank you!

  2. #2
    Join Date
    Feb 2006
    Munich, Germany
    Thanked 831 Times in 780 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    MacOS X Unix/X11 Windows

    Default Re: Convert canvas coordinates to parent widget

    First you need to translate the curve points into widget coordinates of the canvas. This can be done using the maps you get with QwtPlot::canvasMap().


  3. The following user says thank you to Uwe for this useful post:

    basania (12th April 2019)

Similar Threads

  1. Replies: 0
    Last Post: 28th March 2013, 00:22
  2. Replies: 1
    Last Post: 11th March 2011, 19:34
  3. Replies: 0
    Last Post: 4th May 2010, 09:45
  4. Replies: 7
    Last Post: 14th January 2010, 08:47
  5. style widget on canvas (qgv)
    By valtovar in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2008, 00:31

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.