Qt transparent window graphic card

  • Hello,

    I have a transparent application window in Qt. This windows contains elements such as rectangles and buttons. On some computers, everything works fine (the main window is transparent and I see the items on the window). On other computers, instead of being transparent, the window is black.

    Important: Transparency seems to work if the transparent object is a rectangle in the application window but not if its the ApplicationWindow.

    1. I know these other computers can manage window transparency because I tried other commercial software with transparency and it works. I just don't know how to do it with Qt 5.

    2. Worst case scenario: I guess it's related to the graphic card. In my software, could I ask if the graphic card has the required specs (I don't know what spec is required for transparency) ? How could I do that ?

    Here is a simple code to reproduce the problem:

    ApplicationWindow {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
            width: 150
            height: 150

    Thank you very much,


  • Lifetime Qt Champion


    What version of Qt are you using and what OS are you targeting ?

  • Sorry, I thought I detailed this.
    I am using Qt5 with MinGW 5.7.
    I compile with Windows 8 and I want ii to work on Windows xp,7,8,10

  • Lifetime Qt Champion

    And on what Windows version do you have that problem ?

  • On Windows 8 and Windows 10 I don't have this problem. However it may be a coincidence.
    Indeed, I don't have this problem on a Win7 desktop (NVIDIA graphic card) I have but I have the problem on another Win7 desktop (ATI RADEON).

    I have seen similar problem in other threads (transparent appears as black) but no solution seemed to work.



  • There seems to be a bug report here from 2013 but it's not my field of expertise and I don't see any solution.

  • @SGaist

    I couldn't test right now but there are reports it works if the aero theme is set:

    However, I can't ask people to set an aero theme. Is it possible to force something similar in my Qt code ?

    Also, there is some software that use transparency (and works) on all these computers without the aero theme. But I don't think they were designed with Qt. One of them was designed with Qt (I see the file QtCore4.dll) but it was Qt4. I think the bug is for Qt5.

    Thanks !

  • I tested with the new Qt5.9 beta and it's the same problem.

  • Lifetime Qt Champion

    Can you try forcing your application to use the desktop OpenGL ?

  • @SGaist Thank you for your answer.

    From this link (http://doc.qt.io/qt-5/configure-options.html), they say to do "configure.bat -opengl desktop". I didn't do that, since I don't know how to do that but I found another way to include OpenGL, see the following.

    And from here (http://doc.qt.io/qt-5/qtopengl-index.html), they say for opengl : "Warning: This module should not be used anymore for new code. Please use the corresponding OpenGL classes in Qt GUI."
    From this same page, I include "#include <QtOpenGL>" and "QT += opengl" but it didn't change anything. I think it's normal since as I understand I should create a QWindow instead of my Application Window. However, I did not find how to mix QWindow and QML.

    Thank you very much,


  • Lifetime Qt Champion

    No need for compilation, just set the Qt::AA_UseDesktopOpenGL application attribute..

  • @SGaist Thank you for your answer.

    I tried setting Qt::AA_UseDesktopOpenGL in my QML with flags but it did not work.
    I the documentation it says: "This attribute must be set before Q(Gui)Application is constructed."
    So I tried the following but the window is still black instead of being transparent. I guess it was the right way to set this attribute but I'm not sure.

    Thank you again,


    int main(int argc, char *argv[])
        QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL, true);
        QApplication app(argc, argv);
        QQmlApplicationEngine engine;

  • Lifetime Qt Champion

    Do you know what graphic card is used when your application fails ?

  • Both NVIDIA graphic card or ATI RADEON fails in Win7 if the theme is not set to AERO.

  • Lifetime Qt Champion

    Ok, then you should take a look at the bug report system to see if it's something known.

    Note that Vista has reached EOL on April 11 this year.

Log in to reply

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