Hi there,
I'm using customGL widget which derived from QGLWidget. I wanna use QRubberBand on this widget my code like this ;
{
Q_OBJECT
public:
private:
protected:
void initializeGL();
void resizeGL(int w, int h);
//void paintGL();
};
{
origin = e->pos();
if (!rubberBand)
rubberBand->show();
}
{
rubberBand
->setGeometry
(QRect(origin, e
->pos
()).
normalized());
}
{
rubberBand->hide();
}
class HSGLWidget : public QGLWidget
{
Q_OBJECT
public:
HSGLWidget(QWidget *parent = 0);
private:
QRubberBand *rubberBand;
QPoint origin;
protected:
void initializeGL();
void resizeGL(int w, int h);
//void paintGL();
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
};
void HSGLWidget::mousePressEvent( QMouseEvent *e )
{
origin = e->pos();
if (!rubberBand)
rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
rubberBand->setGeometry(QRect(origin, QSize()));
rubberBand->show();
}
void HSGLWidget::mouseMoveEvent( QMouseEvent *e )
{
rubberBand->setGeometry(QRect(origin, e->pos()).normalized());
}
void HSGLWidget::mouseReleaseEvent(QMouseEvent *e)
{
rubberBand->hide();
}
To copy to clipboard, switch view to plain text mode
It's working with this implementation but there is something weird when i press the mouse button and moving mouse i see many Qrubberband flooding on the HSGLWidget if i move mouse quickly there is few if move slowly there is huge flooding. What is the problem am i using something wrong or this is QRubberBand issue , thanks for you help.
Bookmarks