making a RubberBand for selecting an area
Hi,
I need to select an area with a RubberBand that returns QRectF::top, QRectF::bottom, QRectF::left, QRectF::right. For this I do this:
Code:
zoomer
->setRubberBandPen
( QColor( Qt
::red ) );
zoomer
->setTrackerPen
( QColor( Qt
::green ) );
Qt::RightButton, Qt::ControlModifier );
Qt::RightButton );
and by using zoomed (const QRectF &rect) signal, rect can be obtain.
Code:
void MyClass
::slot_pos(QRectF pos
) {
qDebug() << pos.top << pos.bottom << pos.left << pos.right;
}
now I have this problem:
Mouse LeftButton causes zooming. I want to to select an area with a RubberBand without zooming by for example LeftButton +ctrl.
Re: making a RubberBand for selecting an area
QwtPlotZoomer - zooming = QwtPlotPicker;
The keys or mouse actions being used for starting,moving and terminating the selection is customizable.
Uwe
Re: making a RubberBand for selecting an area
Thanks Uwe, I used this and nothing happens and no RubberBand has been appeared:
Code:
picker
->setRubberBandPen
( QColor( Qt
::red ) );
picker
->setTrackerPen
( QColor( Qt
::green ) );
Qt::RightButton, Qt::ControlModifier );
Re: making a RubberBand for selecting an area
This is your initial sequence to get something started:
Code:
picker
->setRubberBandPen
( QColor( Qt
::red ) );
picker
->setTrackerPen
( QColor( Qt
::green ) );
connect( picker,
SIGNAL( selected
( const QRectF &rect
) ), ...
);
Choose the type of state machine you like and check its docs, what type of event patterns are used by it. In case of the rectangle machines it is using QwtEventPattern::MouseSelect1 and QwtEventPattern::KeySelect1 - what means changing QwtEventPattern::MouseSelect2 ( like in your code snippet ) will have no effect.
Uwe