I have a similar question to the OP, so I'll put it here rather than starting a new thread, just to keep it all in context.
How does one temporarily fill the rectangular rubberband area with a translucent color? (I want the fill visible only while the rubber band is being drawn.)
My attempt was to override QwtPicker and re-implement drawRubberBand(), however this code actually does nothing. And even commenting-out the parent call at the end still results in the rectangular zoom outline being drawn. So I'm confused. Any advice Uwe would be appreciated.
SETUP
m_picker
= new XQwtPicker
( QwtPicker::RectRubberBand,
this->canvas() );
m_picker
->setRubberBandPen
( QColor( Qt
::green ) );
m_picker
->setRubberBand
( QwtPicker::CrossRubberBand );
m_picker
->setTrackerPen
( QColor( Qt
::white ) );
m_picker = new XQwtPicker( QwtPicker::RectRubberBand,
QwtPicker::AlwaysOn,
this->canvas() );
m_picker->setRubberBandPen( QColor( Qt::green ) );
m_picker->setRubberBand( QwtPicker::CrossRubberBand );
m_picker->setTrackerPen( QColor( Qt::white ) );
To copy to clipboard, switch view to plain text mode
SUBCLASS
void XQwtPicker
::drawRubberBand( QPainter *painter
) const {
const QRect rect
= QRect( pa.
first(), pa.
last() ).
normalized();
fillColor.setAlpha(125);
// QwtPicker::drawRubberBand(painter);
}
void XQwtPicker::drawRubberBand( QPainter *painter ) const
{
const QPolygon pa = QwtPicker::selection();
const QRect rect = QRect( pa.first(), pa.last() ).normalized();
QColor fillColor = QwtPicker::rubberBandPen().color();
fillColor.setAlpha(125);
QBrush fillBrush(fillColor);
QwtPainter::fillRect( painter, rect, fillBrush );
// QwtPicker::drawRubberBand(painter);
}
To copy to clipboard, switch view to plain text mode
Bookmarks