Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt transparent window graphic card

Qt transparent window graphic card

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
15 Posts 2 Posters 5.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alecs26
    wrote on last edited by
    #1

    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")
    
        color:"transparent"
    
        Rectangle
        {
            width: 150
            height: 150
            color:"red"
        }
    }
    

    Thank you very much,

    Alex

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alecs26
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          And on what Windows version do you have that problem ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alecs26
            wrote on last edited by
            #5

            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.

            Thanks,

            Alex

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alecs26
              wrote on last edited by
              #6

              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.
              https://bugreports.qt.io/browse/QTBUG-28214

              1 Reply Last reply
              0
              • A Offline
                A Offline
                alecs26
                wrote on last edited by alecs26
                #7

                @SGaist

                I couldn't test right now but there are reports it works if the aero theme is set:
                http://stackoverflow.com/questions/42059468/qt-quick2-window-cant-be-transparent-without-aero

                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 !

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alecs26
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

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

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alecs26
                      wrote on last edited by alecs26
                      #10

                      @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,

                      Alex

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

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

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          alecs26
                          wrote on last edited by
                          #12

                          @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,

                          Alex

                          int main(int argc, char *argv[])
                          {
                              QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
                              QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL, true);
                              QApplication app(argc, argv);
                          
                              QQmlApplicationEngine engine;
                              ...
                          
                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

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

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              alecs26
                              wrote on last edited by
                              #14

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

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                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.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved