Results 1 to 2 of 2

Thread: QwtPlotZoomer: cut of markers close to canvas borders

  1. #1
    Join Date
    Jul 2010
    Qt products

    Default QwtPlotZoomer: cut of markers close to canvas borders

    Hello you all, I'm usign QT 4.7 and QWT 6.0.0 RC5

    In a previous post I looked for suggests to implement a railway flow, and thanks to your advices I made the work.
    At the present I'm in trouble with the use of QwtPlotZoomer. I'm using it to control automatically the zoom with mouse facilities patterns.
    When the user zoom in and zoom out into the zoom stack, no problem.
    When the user choose the maximum zoom out the curves are plotted too close the border of the canvas, cutting off some markers. Please see the comparison shots attached.

    How can I fix this issue ? I would that zoom doesn't cut off the labels of the qwtplotmarkers.
    Attached Images Attached Images

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

    Default Re: QwtPlotZoomer: cut of markers close to canvas borders

    Well, all texts of your screenshots are so blurred, that I can only guess.

    With QwtPlotMarker::setLabelAlignment() you can define, how the text label of a marker is aligned to its position - but what you are looking for is some sort of auto-placement, that takes care, that the label is always visible.

    So you have to derive from QwtPlotMarker and overload - hmm ... drawLabel is not virtual, so it is QwtPlotMarker::draw. Do something like this:

    Qt Code:
    1. void YourMarker::draw( QPainter *painter,
    2. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    3. const QRectF &canvasRect ) const
    4. {
    5. const QPointF pos(
    6. xMap.transform( xValue() ), yMap.transform( yValue() );
    8. symbol().drawSymbol( painter, pos );
    10. const QSizeF textSize = label().textSize( painter->font() );
    12. QRectF textRect = ... // do your auto placement
    14. label().draw( painter, textRect );
    15. }
    To copy to clipboard, switch view to plain text mode 


Similar Threads

  1. Replies: 2
    Last Post: 17th December 2010, 19:01
  2. how to set markers below a slider in qt
    By qt_user in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2010, 07:02
  3. Markers are not removed from QwtPlot
    By MuzZviman in forum Qwt
    Replies: 1
    Last Post: 3rd June 2010, 07:25
  4. Help: How to draw markers on plot?
    By jwieland in forum Qwt
    Replies: 5
    Last Post: 24th November 2009, 11:22
  5. qscintilla and markers
    By sawerset in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2009, 21:39

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.