Important: Please read the Qt Code of Conduct -

[Solved] QRubberBand and QGLWidget

  • Hello,
    I have a problem with QRubberBand, it's not transparent on QGLWidget. On QWidget QRubberBand draws pretty blue rectangle, but on QGLWidget he draws not transparent blue rectangle. I read some posts where people advised to set to QRubberBand::setWindowFlags(Qt::ToolTip); it fixes transparent problem, but draws rectangle in another position, not where user click, and I think that this solution not good.
    Any suggestion?

  • Hm, strange no ideas at all?

  • Maybe you could provide a simple compilable example which shows the problem.

    If it is a bug this will help resolve the issue.

    Or someone can point you to something wrong.

    or by stripping down the problem to it's essential you discover what is wrong.

  • Sorry, for long silence, work. I was a little honest with QGLWidget, because I have QGLWidget as a viewport of QGraphicsView and I know about QGraphicsView::RubberBandDrag, but I need to draw QRubberBand in another place. So, I create QRubberBand like this
    QRubberBand *rubberBand = QRubberBand(QRubberBand::Rectangle, graphicsView);
    in this case QRubberBand draws rectangle with blue brush and not transparent, so I didn't see any items.
    Then I remember that it is necessary to set parent as viewport:
    QRubberBand *rubberBand = QRubberBand(QRubberBand::Rectangle, graphicsView->viewport());
    in this case QRubberBand draws rectangle with no brush, only lines with dark blue color.

  • Sorry, just test count of points I've get when reply on post. I think I've got 5 points against 2.
    [Update]: indeed 5 points. Oh here is new Points&Ranks rules.

Log in to reply