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:
void YourMarker
::draw( QPainter *painter,
const QRectF &canvasRect
) const {
xMap.transform( xValue() ), yMap.transform( yValue() );
symbol().drawSymbol( painter, pos );
const QSizeF textSize
= label
().
textSize( painter
->font
() );
QRectF textRect
= ...
// do your auto placement
label().draw( painter, textRect );
}
void YourMarker::draw( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect ) const
{
const QPointF pos(
xMap.transform( xValue() ), yMap.transform( yValue() );
symbol().drawSymbol( painter, pos );
const QSizeF textSize = label().textSize( painter->font() );
QRectF textRect = ... // do your auto placement
label().draw( painter, textRect );
}
To copy to clipboard, switch view to plain text mode
Uwe
Bookmarks