How to overlay a QWidget such as QLabel overy a Qt 5.0 QWindow with the transparent part works like QWidget overly QWidget?

  • When I use a QLabel overly a QWindow by
    #include "paintedwindow.h"
    #include "ScadeWidget.h"

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <QLabel>

    ScadeWidget::ScadeWidget(QWidget *parent):QWidget(parent)
    scadeWindow = new PaintedWindow;

    // Combining Qt Widgets and QML with QWidget::createWindowContainer()
    // OpenGL in Qt 5.1 – Part 5
    // OpenGL Window Example
    container = QWidget::createWindowContainer(scadeWindow, this);
    container->setMinimumSize(scadeWindow->width(), scadeWindow->height());

    #if 1
    //We can directly use Qt UI file to overlap OpenGL.
    auto label = new QLabel("Hello, the world!", this);
    label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    The showed label comes with non-transparent staff. Ineed, the paintedwindow comes from the qt
    examples C:\Qt\Qt5.1.1\5.1.1\msvc2010_opengl\examples\opengl\paintedwindow

    as the following picture shows, the hello world's background should be blue :
    ! in transparent draw.)!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.