Solved QML window is always empty
-
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?
-
@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
-
Please include 'backend.h' file for testing purposes.
-
Sorry, i forgot to remove it. I updated post.
-
@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?
-
@Markkyboy Problem is that after compilation i see just an empty window. Like this:
And in every other application with qml i see just an empty window. (i tried many apps from qt library of examples) -
@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.
-
@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; -
@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 -
@bronstein87 Do you see any warning in the console when running your app?
-
@jsulm Hi. I made clean and rebuilt project. And how you can see there is no any warnings or unusual messages...
-
@bronstein87 might be a driver / open gl issue
what os do you use and what graphic-card and are those drivers up to date?
-
@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. -
@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 ?
-
@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
-
@KroMignon Yes, i'm working per remote session. Thank you, this seems to be the reason, i'll check tomorrow.
-
@KroMignon You was right. Thank you.
-
@bronstein87 Your welcome