Unsolved 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
mousePressEvent
that's reimplemented to setup the rubber band, thenmouseMoveEvent
to handle it's geometry and finallymouseReleaseEvent
to hide it. -
O dear I did mess it up ! Blah silly me! Will give it a go thanks so much!