QRubberBand + QGLWidget + Transparency
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":http://developer.qt.nokia.com/forums/viewthread/6544/
I also found another thread pointing to an article teaching semitransparent QWidgets behind QGLWidget: "here":http://doc.qt.nokia.com/qq/qq26-openglcanvas.html
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
I also found "this answer":http://developer.qt.nokia.com/faq/answer/is_it_possible_to_have_transparent_qt_widgets_on_top_of_a_qglwidget, but it sounds old or false.