Results 1 to 9 of 9

Thread: How to show xy coordinate on QLabel widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    18
    Thanked 5 Times in 5 Posts

    Question Re: How to show xy coordinate on QLabel widget

    Hi to Everyone,
    i want the xy-coordinates too, but i want to save it to an integer or a double to display a Marker with a mouse click.
    I had connected the Signal as UWE described and the signal is working. But i did not get the values, which are shown next to the mouse at the QwtPlot. e.g. (22000, 800). I only get from d_picker->trackerPosition() something like (139,81) which seem to be the pixel coordinates of the window.

    My Question is:
    How can i retrieve or transform the data "behind" the pixel-coordinates {like: (22000, 800) } ?
    Or which additional Signal, must i connect to get the data which is displayed next to the mouse pointer?

    thanks in advance,
    Astronomy

    here's my code:

    Qt Code:
    1. CPlot::CPlot() // constructor
    2.  
    3. // Crosslines of the mouse - SELECTION
    4. d_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft, QwtPicker::PointSelection | QwtPicker::DragSelection,
    5. QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, this->canvas());
    6. d_picker->setRubberBandPen(QColor(Qt::green));
    7. d_picker->setRubberBand(QwtPicker::CrossRubberBand);
    8. connect(d_picker, SIGNAL(moved(const QPoint &)), SLOT(moved(const QPoint &)));
    9. connect(d_picker, SIGNAL(selected(const QwtPolygon &)), SLOT(selected(const QwtPolygon &)));
    10. // connect(d_picker, SIGNAL(selected(const QwtDoublePoint &)), SLOT(selected(const QwtDoublePoint &)));
    11.  
    12. ...[B] // as Uwe said..[/B]
    13. connect(d_picker, SIGNAL(selected(const QwtDoublePoint & )), SLOT(DrawMarkers()) );
    14. ...
    To copy to clipboard, switch view to plain text mode 

    // My Signal of my QwtPlot derivation...
    Qt Code:
    1. void CPlot::DrawMarkers()
    2. {
    3. // Here the Markers for the selection will be placed on the plot..
    4. QwtPlotMarker *cSelectionMarker = new QwtPlotMarker();
    5. cSelectionMarker->setLabel(QString::fromLatin1("x-Selection"));
    6. cSelectionMarker->setLabelAlignment(Qt::AlignLeft | Qt::AlignBottom);
    7. cSelectionMarker->setLabelOrientation(Qt::Vertical);
    8. cSelectionMarker->setLineStyle(QwtPlotMarker::VLine);
    9. cSelectionMarker->setLinePen(QPen(Qt::red, 0, Qt::DashDotLine));
    10.  
    11. int Test = 0;
    12. // QwtDoublePoint pos;
    13. QPoint pos;
    14. pos = d_picker->trackerPosition();
    15. test = pos.rx(); // only for debugging: result was 139, seem to be the coordinates of the Window
    16. test = pos.ry(); // debugging resultwas : 81 seem to be the coordinates of the Window
    17.  
    18.  
    19. test = d_picker->yAxis(); // debugging: result was 0, this comes from the constructor as a result of QwtPlot::yLeft
    20. test = d_picker->xAxis(); // debugging: result was 2, this comes from the constructor as a result of QwtPlot::xBottom
    21.  
    22. //d_picker->trackerText(pos);
    23.  
    24.  
    25. cSelectionMarker->setXValue( test ); //Set the Marker at mouseclick, not ok
    26. // cSelectionMarker->setXValue( 23000 ); //hardcoded Test, ok
    27. cSelectionMarker->attach(this);
    28. replot();
    29. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Astronomy; 9th February 2010 at 18:28.

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Show dock widget frame/border
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 21st May 2009, 10:04
  3. How to show the widget?
    By kommu in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2008, 08:43
  4. Replies: 4
    Last Post: 4th February 2008, 06:16
  5. How to show custom widget in TreeView's cell :-/
    By WolfMM in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2007, 11:16

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
  •  
Qt is a trademark of The Qt Company.