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. QML window is always empty
Forum Updated to NodeBB v4.3 + New Features

QML window is always empty

Scheduled Pinned Locked Moved Solved QML and Qt Quick
17 Posts 5 Posters 1.9k Views
  • 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.
  • B Offline
    B Offline
    bronstein87
    wrote on last edited by bronstein87
    #1

    Hi. I'm trying to develop gui using QML but after compilation i always get an empty window. I tried to run some of examples with qml, they are also show just empty window. I tried different compilers (mingw 64, msvc15 64) , different qt version (5.12.2, 5.14), but always get same result. Platform win10 x64. Example of application:

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        const QUrl url(QStringLiteral("qrc:/main.qml"));
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
    
        return app.exec();
    }
    

    main.qml

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Layouts 1.12
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Rectangle
        {
            color : "red"
            width: 100
            height:100
        }
    
        TextField {
            text: "NEED HELP"
            placeholderText: qsTr("User name")
            anchors.centerIn: parent
        }
    }
    

    What is wrong?

    1 Reply Last reply
    0
    • B bronstein87

      @J-Hilk I added this attribute and now everything works

      QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL );
      

      But it seems to me that usage of software opengl is not a good idea in terms of performance. Do you have any thoughts about how to force it to work with Qt::AA_UseDesktopOpenGL ?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by KroMignon
      #14

      @bronstein87 Are you working per remote session (TeamViewer) or directly on PC? I've got troubles with QML/OpenGL and TeamViewer and often only got an empty view.

      If you are using TeamViewer, take at look at this thread: https://community.teamviewer.com/t5/General-Questions/Some-applications-does-not-show-content-white-window-Windows-10/td-p/10718

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      B 2 Replies Last reply
      3
      • MarkkyboyM Offline
        MarkkyboyM Offline
        Markkyboy
        wrote on last edited by
        #2

        Please include 'backend.h' file for testing purposes.

        Don't just sit there standing around, pick up a shovel and sweep up!

        I live by the sea, not in it.

        1 Reply Last reply
        1
        • B Offline
          B Offline
          bronstein87
          wrote on last edited by
          #3

          Sorry, i forgot to remove it. I updated post.

          MarkkyboyM 1 Reply Last reply
          0
          • B bronstein87

            Sorry, i forgot to remove it. I updated post.

            MarkkyboyM Offline
            MarkkyboyM Offline
            Markkyboy
            wrote on last edited by
            #4

            @bronstein87 - cool, I also removed everything related to 'backend.h' and your code runs, what is the problem?, did you try running the code with all backend stuff removed?, what is it you are trying to achieve exactly?

            Don't just sit there standing around, pick up a shovel and sweep up!

            I live by the sea, not in it.

            B 1 Reply Last reply
            0
            • MarkkyboyM Markkyboy

              @bronstein87 - cool, I also removed everything related to 'backend.h' and your code runs, what is the problem?, did you try running the code with all backend stuff removed?, what is it you are trying to achieve exactly?

              B Offline
              B Offline
              bronstein87
              wrote on last edited by bronstein87
              #5

              @Markkyboy Problem is that after compilation i see just an empty window. Like this:
              window after compilation
              And in every other application with qml i see just an empty window. (i tried many apps from qt library of examples)

              MarkkyboyM 2 Replies Last reply
              0
              • B bronstein87

                @Markkyboy Problem is that after compilation i see just an empty window. Like this:
                window after compilation
                And in every other application with qml i see just an empty window. (i tried many apps from qt library of examples)

                MarkkyboyM Offline
                MarkkyboyM Offline
                Markkyboy
                wrote on last edited by
                #6

                @bronstein87 - sorry, silly question, re: "what's the problem?", you had already stated as much.

                I'm using Windows 7 Ultimate x64 with QtCreator 4.11.1 (MSVC 2017, 32bit) and your code works when all backend related stuff is removed.

                Could it be a Windows10 problem I wonder?, I don't know what else to say, sorry.

                Don't just sit there standing around, pick up a shovel and sweep up!

                I live by the sea, not in it.

                1 Reply Last reply
                0
                • B bronstein87

                  @Markkyboy Problem is that after compilation i see just an empty window. Like this:
                  window after compilation
                  And in every other application with qml i see just an empty window. (i tried many apps from qt library of examples)

                  MarkkyboyM Offline
                  MarkkyboyM Offline
                  Markkyboy
                  wrote on last edited by
                  #7

                  @bronstein87 - I suggest scrapping the current project and starting again. looking at your screenshot, I see remains of 'backend' files, perhaps this is causing problems?, admittedly, this is all guess work on my behalf.
                  For what it is worth, here is a screenshot of my set up running your code;

                  empty window qml.JPG

                  Don't just sit there standing around, pick up a shovel and sweep up!

                  I live by the sea, not in it.

                  B 1 Reply Last reply
                  0
                  • MarkkyboyM Markkyboy

                    @bronstein87 - I suggest scrapping the current project and starting again. looking at your screenshot, I see remains of 'backend' files, perhaps this is causing problems?, admittedly, this is all guess work on my behalf.
                    For what it is worth, here is a screenshot of my set up running your code;

                    empty window qml.JPG

                    B Offline
                    B Offline
                    bronstein87
                    wrote on last edited by
                    #8

                    @Markkyboy no, i tried many different projects and configurations of current project, result is the same.
                    I think something is missing in the system, maybe some libraries or paths are missing. or some wrong settings in qt itself

                    jsulmJ 1 Reply Last reply
                    0
                    • B bronstein87

                      @Markkyboy no, i tried many different projects and configurations of current project, result is the same.
                      I think something is missing in the system, maybe some libraries or paths are missing. or some wrong settings in qt itself

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      @bronstein87 Do you see any warning in the console when running your app?

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      B 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @bronstein87 Do you see any warning in the console when running your app?

                        B Offline
                        B Offline
                        bronstein87
                        wrote on last edited by
                        #10

                        @jsulm Hi. I made clean and rebuilt project. And how you can see there is no any warnings or unusual messages...
                        alt text

                        J.HilkJ 1 Reply Last reply
                        0
                        • B bronstein87

                          @jsulm Hi. I made clean and rebuilt project. And how you can see there is no any warnings or unusual messages...
                          alt text

                          J.HilkJ Offline
                          J.HilkJ Offline
                          J.Hilk
                          Moderators
                          wrote on last edited by
                          #11

                          @bronstein87 might be a driver / open gl issue

                          what os do you use and what graphic-card and are those drivers up to date?


                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                          Q: What's that?
                          A: It's blue light.
                          Q: What does it do?
                          A: It turns blue.

                          B 2 Replies Last reply
                          0
                          • J.HilkJ J.Hilk

                            @bronstein87 might be a driver / open gl issue

                            what os do you use and what graphic-card and are those drivers up to date?

                            B Offline
                            B Offline
                            bronstein87
                            wrote on last edited by
                            #12

                            @J-Hilk Hi. I also thought about that, but drivers up to date (i have just checked).
                            OS - win10 x64, graphic-card - GeForce RTX 2060 SUPER.

                            1 Reply Last reply
                            0
                            • J.HilkJ J.Hilk

                              @bronstein87 might be a driver / open gl issue

                              what os do you use and what graphic-card and are those drivers up to date?

                              B Offline
                              B Offline
                              bronstein87
                              wrote on last edited by bronstein87
                              #13

                              @J-Hilk I added this attribute and now everything works

                              QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL );
                              

                              But it seems to me that usage of software opengl is not a good idea in terms of performance. Do you have any thoughts about how to force it to work with Qt::AA_UseDesktopOpenGL ?

                              KroMignonK 1 Reply Last reply
                              0
                              • B bronstein87

                                @J-Hilk I added this attribute and now everything works

                                QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL );
                                

                                But it seems to me that usage of software opengl is not a good idea in terms of performance. Do you have any thoughts about how to force it to work with Qt::AA_UseDesktopOpenGL ?

                                KroMignonK Offline
                                KroMignonK Offline
                                KroMignon
                                wrote on last edited by KroMignon
                                #14

                                @bronstein87 Are you working per remote session (TeamViewer) or directly on PC? I've got troubles with QML/OpenGL and TeamViewer and often only got an empty view.

                                If you are using TeamViewer, take at look at this thread: https://community.teamviewer.com/t5/General-Questions/Some-applications-does-not-show-content-white-window-Windows-10/td-p/10718

                                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                B 2 Replies Last reply
                                3
                                • KroMignonK KroMignon

                                  @bronstein87 Are you working per remote session (TeamViewer) or directly on PC? I've got troubles with QML/OpenGL and TeamViewer and often only got an empty view.

                                  If you are using TeamViewer, take at look at this thread: https://community.teamviewer.com/t5/General-Questions/Some-applications-does-not-show-content-white-window-Windows-10/td-p/10718

                                  B Offline
                                  B Offline
                                  bronstein87
                                  wrote on last edited by bronstein87
                                  #15

                                  @KroMignon Yes, i'm working per remote session. Thank you, this seems to be the reason, i'll check tomorrow.

                                  1 Reply Last reply
                                  0
                                  • KroMignonK KroMignon

                                    @bronstein87 Are you working per remote session (TeamViewer) or directly on PC? I've got troubles with QML/OpenGL and TeamViewer and often only got an empty view.

                                    If you are using TeamViewer, take at look at this thread: https://community.teamviewer.com/t5/General-Questions/Some-applications-does-not-show-content-white-window-Windows-10/td-p/10718

                                    B Offline
                                    B Offline
                                    bronstein87
                                    wrote on last edited by
                                    #16

                                    @KroMignon You was right. Thank you.

                                    KroMignonK 1 Reply Last reply
                                    0
                                    • B bronstein87

                                      @KroMignon You was right. Thank you.

                                      KroMignonK Offline
                                      KroMignonK Offline
                                      KroMignon
                                      wrote on last edited by
                                      #17

                                      @bronstein87 Your welcome

                                      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                                      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