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 21 Mar 2020, 14:25 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
      23 Mar 2020, 10:36

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

      K Offline
      K Offline
      KroMignon
      wrote on 23 Mar 2020, 15:47 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 23 Mar 2020, 15:49
      3
      • M Offline
        M Offline
        Markkyboy
        wrote on 22 Mar 2020, 09:50 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 22 Mar 2020, 10:16 last edited by
          #3

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

          M 1 Reply Last reply 22 Mar 2020, 10:19
          0
          • B bronstein87
            22 Mar 2020, 10:16

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

            M Offline
            M Offline
            Markkyboy
            wrote on 22 Mar 2020, 10:19 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 22 Mar 2020, 10:27
            0
            • M Markkyboy
              22 Mar 2020, 10:19

              @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 22 Mar 2020, 10:27 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)

              M 2 Replies Last reply 22 Mar 2020, 10:35
              0
              • B bronstein87
                22 Mar 2020, 10:27

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

                M Offline
                M Offline
                Markkyboy
                wrote on 22 Mar 2020, 10:35 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
                  22 Mar 2020, 10:27

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

                  M Offline
                  M Offline
                  Markkyboy
                  wrote on 22 Mar 2020, 11:04 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 22 Mar 2020, 11:42
                  0
                  • M Markkyboy
                    22 Mar 2020, 11:04

                    @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 22 Mar 2020, 11:42 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 23 Mar 2020, 06:16
                    0
                    • B bronstein87
                      22 Mar 2020, 11:42

                      @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 23 Mar 2020, 06:16 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 23 Mar 2020, 09:57
                      0
                      • jsulmJ jsulm
                        23 Mar 2020, 06:16

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

                        B Offline
                        B Offline
                        bronstein87
                        wrote on 23 Mar 2020, 09:57 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 23 Mar 2020, 09:59
                        0
                        • B bronstein87
                          23 Mar 2020, 09:57

                          @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 23 Mar 2020, 09:59 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 23 Mar 2020, 10:20
                          0
                          • J.HilkJ J.Hilk
                            23 Mar 2020, 09:59

                            @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 23 Mar 2020, 10:20 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
                              23 Mar 2020, 09:59

                              @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 23 Mar 2020, 10:36 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 ?

                              K 1 Reply Last reply 23 Mar 2020, 15:47
                              0
                              • B bronstein87
                                23 Mar 2020, 10:36

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

                                K Offline
                                K Offline
                                KroMignon
                                wrote on 23 Mar 2020, 15:47 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 23 Mar 2020, 15:49
                                3
                                • K KroMignon
                                  23 Mar 2020, 15:47

                                  @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 23 Mar 2020, 15:49 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
                                  • K KroMignon
                                    23 Mar 2020, 15:47

                                    @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 24 Mar 2020, 13:18 last edited by
                                    #16

                                    @KroMignon You was right. Thank you.

                                    K 1 Reply Last reply 24 Mar 2020, 13:37
                                    0
                                    • B bronstein87
                                      24 Mar 2020, 13:18

                                      @KroMignon You was right. Thank you.

                                      K Offline
                                      K Offline
                                      KroMignon
                                      wrote on 24 Mar 2020, 13:37 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

                                      1/17

                                      21 Mar 2020, 14:25

                                      • Login

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