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. Translucent background not rendering correctly in Qt6 with hardware rendering but works with Software rendering
Forum Updated to NodeBB v4.3 + New Features

Translucent background not rendering correctly in Qt6 with hardware rendering but works with Software rendering

Scheduled Pinned Locked Moved Solved QML and Qt Quick
14 Posts 3 Posters 2.1k Views 2 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.
  • J JoeCFD
    27 Feb 2023, 19:37

    @Muhammad-Hassan-Shahid
    Can you try:
    QQuickWindow::setSceneGraphBackend( QSGRendererInterface::OpenGL );

    The other options are here:
    https://doc.qt.io/qt-6/qsgrendererinterface.html

    M Offline
    M Offline
    Muhammad Hassan Shahid
    wrote on 28 Feb 2023, 14:56 last edited by Muhammad Hassan Shahid
    #4

    @JoeCFD When I use the QSGRendererInterface enums, compiler gives me an error that it can't convert it to Qstring and indeed there is no overload of QQuickWindow::setSceneGraphBackend for parameter of type QSGRendererInterface::GraphicsApi

    J 1 Reply Last reply 28 Feb 2023, 15:25
    0
    • M Muhammad Hassan Shahid
      28 Feb 2023, 14:56

      @JoeCFD When I use the QSGRendererInterface enums, compiler gives me an error that it can't convert it to Qstring and indeed there is no overload of QQuickWindow::setSceneGraphBackend for parameter of type QSGRendererInterface::GraphicsApi

      J Offline
      J Offline
      JoeCFD
      wrote on 28 Feb 2023, 15:25 last edited by JoeCFD
      #5

      @Muhammad-Hassan-Shahid Sorry you call this one
      void QQuickWindow::setGraphicsApi(QSGRendererInterface::GraphicsApi api)

      The source code is here
      https://codebrowser.dev/qt6/qtdeclarative/src/quick/items/qquickwindow.cpp.html
      check line 3773
      there are only two options: OpenVG may be the one you need.

          // Special cases: these are different scenegraph backends.
          switch (api) {
          case QSGRendererInterface::Software:
              setSceneGraphBackend(QStringLiteral("software"));
              break;
          case QSGRendererInterface::OpenVG:
              setSceneGraphBackend(QStringLiteral("openvg"));
              break;
          default:
              break;
          }
      

      https://doc.qt.io/qt-6/qtquick-visualcanvas-adaptations-openvg.html

      M 1 Reply Last reply 28 Feb 2023, 16:24
      0
      • J JoeCFD
        28 Feb 2023, 15:25

        @Muhammad-Hassan-Shahid Sorry you call this one
        void QQuickWindow::setGraphicsApi(QSGRendererInterface::GraphicsApi api)

        The source code is here
        https://codebrowser.dev/qt6/qtdeclarative/src/quick/items/qquickwindow.cpp.html
        check line 3773
        there are only two options: OpenVG may be the one you need.

            // Special cases: these are different scenegraph backends.
            switch (api) {
            case QSGRendererInterface::Software:
                setSceneGraphBackend(QStringLiteral("software"));
                break;
            case QSGRendererInterface::OpenVG:
                setSceneGraphBackend(QStringLiteral("openvg"));
                break;
            default:
                break;
            }
        

        https://doc.qt.io/qt-6/qtquick-visualcanvas-adaptations-openvg.html

        M Offline
        M Offline
        Muhammad Hassan Shahid
        wrote on 28 Feb 2023, 16:24 last edited by
        #6

        @JoeCFD I tried OpenVG but the result the same as the hardware rendering one. It only works with the software rendering.

        J 1 Reply Last reply 28 Feb 2023, 16:29
        0
        • M Muhammad Hassan Shahid
          28 Feb 2023, 16:24

          @JoeCFD I tried OpenVG but the result the same as the hardware rendering one. It only works with the software rendering.

          J Offline
          J Offline
          JoeCFD
          wrote on 28 Feb 2023, 16:29 last edited by JoeCFD
          #7

          @Muhammad-Hassan-Shahid
          check if the backend setting is correct.
          from here:
          QString QQuickWindow::sceneGraphBackend()

          https://www.qt.io/blog/2017/03/31/qt-quick-openvg

          M 1 Reply Last reply 28 Feb 2023, 16:42
          0
          • J JoeCFD
            28 Feb 2023, 16:29

            @Muhammad-Hassan-Shahid
            check if the backend setting is correct.
            from here:
            QString QQuickWindow::sceneGraphBackend()

            https://www.qt.io/blog/2017/03/31/qt-quick-openvg

            M Offline
            M Offline
            Muhammad Hassan Shahid
            wrote on 28 Feb 2023, 16:42 last edited by
            #8

            @JoeCFD The function returns OpenVG but the Qt complains "Could not create scene graph context for backend 'openvg' - check that plugins are installed correctly"

            J 2 Replies Last reply 28 Feb 2023, 17:03
            0
            • M Muhammad Hassan Shahid
              28 Feb 2023, 16:42

              @JoeCFD The function returns OpenVG but the Qt complains "Could not create scene graph context for backend 'openvg' - check that plugins are installed correctly"

              J Offline
              J Offline
              JoeCFD
              wrote on 28 Feb 2023, 17:03 last edited by JoeCFD
              #9

              @Muhammad-Hassan-Shahid said in Translucent background not rendering correctly in Qt6 with hardware rendering but works with Software rendering:

              Could not create scene graph context for backend 'openvg' - check that plugins are installed correctly

              The messages are not very helpful. Which plugins are not installed properly? You have to figure that out. I do not know it either. But you know the reasons now.

              M 1 Reply Last reply 1 Mar 2023, 16:31
              0
              • J JoeCFD
                28 Feb 2023, 17:03

                @Muhammad-Hassan-Shahid said in Translucent background not rendering correctly in Qt6 with hardware rendering but works with Software rendering:

                Could not create scene graph context for backend 'openvg' - check that plugins are installed correctly

                The messages are not very helpful. Which plugins are not installed properly? You have to figure that out. I do not know it either. But you know the reasons now.

                M Offline
                M Offline
                Muhammad Hassan Shahid
                wrote on 1 Mar 2023, 16:31 last edited by
                #10

                @JoeCFD The error is from Qt itself and it doesn't say which plugins exactly. Is there another way this functionality can be achieved in Qt which works with hardware rendering?

                1 Reply Last reply
                0
                • M Muhammad Hassan Shahid
                  28 Feb 2023, 16:42

                  @JoeCFD The function returns OpenVG but the Qt complains "Could not create scene graph context for backend 'openvg' - check that plugins are installed correctly"

                  J Offline
                  J Offline
                  JoeCFD
                  wrote on 1 Mar 2023, 17:39 last edited by JoeCFD 3 Jan 2023, 17:40
                  #11

                  @Muhammad-Hassan-Shahid message in running time or compiling time?
                  Linux or Windows?

                  M 1 Reply Last reply 2 Mar 2023, 16:35
                  0
                  • J JoeCFD
                    1 Mar 2023, 17:39

                    @Muhammad-Hassan-Shahid message in running time or compiling time?
                    Linux or Windows?

                    M Offline
                    M Offline
                    Muhammad Hassan Shahid
                    wrote on 2 Mar 2023, 16:35 last edited by
                    #12

                    @JoeCFD runtime error on windows

                    M 1 Reply Last reply 3 Mar 2023, 15:59
                    0
                    • M Muhammad Hassan Shahid
                      2 Mar 2023, 16:35

                      @JoeCFD runtime error on windows

                      M Offline
                      M Offline
                      Muhammad Hassan Shahid
                      wrote on 3 Mar 2023, 15:59 last edited by
                      #13

                      @Muhammad-Hassan-Shahid The solution is to set ui->quickWidget->quickWindow()->setColor(QColor(0,0,0,0)); after the main window has been rendered to bypass this issue with hardware rendering but this problem should be solved by Qt in the future. There shouldn't be a need to do something like this in the first place.

                      This is the code to reproduce it

                      #include <QQuickWidget>
                      #include <QQuickItem>
                      #include <QQmlError>
                      #include <QtWidgets>

                      class MainWindow : public QMainWindow {
                      Q_OBJECT
                      public:
                      MainWindow();
                      QQuickWidget *m_quickWidget;
                      };

                      MainWindow::MainWindow()
                      : m_quickWidget(new QQuickWidget)
                      {
                      setFixedSize(QSize(800,600));

                      m_quickWidget->setAttribute(Qt::WA_TranslucentBackground);
                      m_quickWidget->setClearColor(Qt::transparent);

                      QUrl source("qrc:transparent.qml");

                      m_quickWidget->resize(300,300);
                      m_quickWidget->setWindowFlags(Qt::SplashScreen);
                      m_quickWidget->setAttribute(Qt::WA_AlwaysStackOnTop);
                      m_quickWidget->setAttribute(Qt::WA_TranslucentBackground);
                      m_quickWidget->setClearColor(Qt::transparent);
                      m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
                      m_quickWidget->setSource(source);

                      QWidget *centralWidget = new QWidget();
                      centralWidget->setStyleSheet("background-color: blue");
                      QHBoxLayout *layout = new QHBoxLayout(centralWidget);
                      layout->addWidget(m_quickWidget);
                      setCentralWidget(centralWidget);
                      }

                      int main(int argc, char **argv)
                      {
                      QApplication app(argc, argv);

                      MainWindow mainWindow;
                      mainWindow.show();

                      mainWindow.m_quickWidget->quickWindow()->setColor(QColor(0,0,0,0));

                      return app.exec();
                      }

                      #include "main.moc"

                      1 Reply Last reply
                      0
                      • M Muhammad Hassan Shahid has marked this topic as solved on 3 Mar 2023, 15:59
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 3 Mar 2023, 19:34 last edited by
                        #14

                        You should open a ticket on the bug report system to make it known to Qt developers.

                        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

                        13/14

                        3 Mar 2023, 15:59

                        • Login

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