Important: Please read the Qt Code of Conduct -

QRubberBand + QGLWidget + Transparency

  • Hello Guys,

    I had this problem I just forgot to fix, because it was not that important in my application. However, now I need it for some tests.

    In my QGLWidget I create a QRubberBand to select subsections of my OpenGL, I really am finding it difficult to make the QRubberBand half transparent.
    I found a post, but I don't have a viewport() to set parent as the problem was solved. "here":
    I also found another thread pointing to an article teaching semitransparent QWidgets behind QGLWidget: "here":
    In their example, the actual OpenGL scene rendering and widget controls are handled in a QGraphicsScene subclass, where the set up of a QGraphicsView with a QGLWidget viewport is performed. But I don't actually want all that in my program. Also, the transparency options used do not solve my problem.

    I have something like:
    QMainWindow parent of a QGLWidget subclass. This subclass is also set as centralWidget.
    Here is what I am trying:
    @origin = event->pos();
    rubberBand= new QRubberBand(QRubberBand::Rectangle, (QWidget*)this);
    rubberBand->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint /| Qt::ToolTip/);
    //tooltip moves coordinate system wrongly, but make it transparent
    rubberBand->setWindowOpacity((qreal)0.5); // no effect adding this line
    rubberBand->setGeometry(QRect(origin, QSize()));

    Any ideas?

Log in to reply