QOpenGLWidget, QRubberBand ?
-
Hey
How can I introduce a selection rectangle to my QOpenGLWidget/context/gl viewport?
I was hoping I could use the QRubberBand and then get its initialPosition + end position to determine the pixels I want, but the rubber band never gets drawn. And its size() return -1,-1;
TIA
-
Hi,
How are you using
QRubberBand? -
Hey
In QOpenGLWidget
initializeGL(){ mAreaSelection = new QRubberBand(QRubberBand::Rectangle, this);// dynamic_cast<QWidget *>(parent())); } mouseMoveEvent(){ if (mMouseDragDistance > 3 && mMouseShiftSelection) { mAreaSelection->setGeometry(QRect(mousePos, QSize())); mAreaSelection->show(); mMouseDragSelection = true; return; } } -
You have mixed things up.
Take a look at the QRubberBand details. There's
mousePressEventthat's reimplemented to setup the rubber band, thenmouseMoveEventto handle it's geometry and finallymouseReleaseEventto hide it.