Results 1 to 2 of 2

Thread: How to fix Plot Marker Label displaying outside of frame/ canvas

  1. #1
    Join Date
    Jun 2016
    Posts
    3
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default How to fix Plot Marker Label displaying outside of frame/ canvas

    I have a plot marker that I want to put a label on. The label is 3 lines (marker #, x coor, y coord). The bottom line is always inside the canvas/ plot window, but the top 2 lines go outside the frame and cannot be seen if the point is close to the y limits of the canvas. I'm not sure how to fix this, I've tried changing the alignment and it doesn't seem to help.


    QwtPlotMarker *temp = marker;
    temp->setXValue(xVal);
    temp->setYValue(yVal);
    temp->show();

    QString label;
    label.sprintf("Marker %d\nX: %.2f\nY: %.2f", i+1,xVal, yVal);
    QwtText text;
    text.setText(label);
    temp->setLabel(text);

  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: How to fix Plot Marker Label displaying outside of frame/ canvas

    Unfortunately there is no public API, where you can modify the bounding rectangle of the label text - all what you have is to overload QwtPlotMarker::drawLabel.
    But the implementation of QwtPlotMarker::drawLabel is no rocket science and you can simply copy out the code to your overloaded method and somehow include the canvas rectangle,

    Uwe

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

    scoutycat (25th July 2016)

Similar Threads

  1. Replies: 10
    Last Post: 7th March 2014, 10:40
  2. Replies: 2
    Last Post: 12th September 2012, 08:43
  3. Zooming the plot without the marker
    By raghvendramisra in forum Qwt
    Replies: 1
    Last Post: 17th May 2012, 18:24
  4. Moving plot marker with the mouse
    By viridis in forum Qwt
    Replies: 2
    Last Post: 23rd September 2008, 21:39
  5. Label for frame
    By brcain in forum Qt Tools
    Replies: 2
    Last Post: 26th September 2006, 00:13

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.