How to overly a transparent QWidget on a QWindow?



  • In the following code, scadeWindow is a instance of customized class ScadeWindow which is a subclass of QWindow. Now I want to put a transparent QLabel on scadeWindow, but failed.
    request for a solution for this problem.

    @
    ScadeWidget::ScadeWidget(QWidget *parent):QWidget(parent)
    {
    QSurfaceFormat format;
    format.setSamples(16);
    scadeWindow = new ScadeWindow(format);

    // Combining Qt Widgets and QML with QWidget::createWindowContainer()
    //  http://www.ics.com/blog/combining-qt-widgets-and-qml-qwidgetcreatewindowcontainer#.UlzdRlAge-U
    // OpenGL in Qt 5.1 – Part 5
    //  http://www.kdab.com/opengl-in-qt-5-1-part-5/
    // OpenGL Window Example
    //  http://qt-project.org/doc/qt-5.1/qtgui/openglwindow.html
    container = QWidget::createWindowContainer(scadeWindow, this);
    container->setAttribute(Qt::WA_TranslucentBackground);
    container->setMinimumSize(scadeWindow->width(), scadeWindow->height());
    auto label = new QLabel("Hello, the world!", this);
    label->setAttribute(Qt::WA_TranslucentBackground);
    label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    

    }
    @
    I use this



  • what if add:

    @label->setStyleSheet("background:transparent");@

    ?


Log in to reply
 

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