Results 1 to 2 of 2

Thread: Convert canvas coordinates to parent widget

  1. #1
    Join Date
    Mar 2019
    Posts
    3
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    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
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    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().

    Uwe

  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, 01:22
  2. Replies: 1
    Last Post: 11th March 2011, 20:34
  3. Replies: 0
    Last Post: 4th May 2010, 10:45
  4. Replies: 7
    Last Post: 14th January 2010, 09:47
  5. style widget on canvas (qgv)
    By valtovar in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2008, 01:31

Tags for this Thread

Bookmarks

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.