Qqmlapplicationengine refuse to show me something
-
wrote on 21 Jun 2013, 13:45 last edited by
Hi all,
Just checked out qt51rc1.
I tried to use qqmlapplicationengine to show a qml file. It seems the application runs silently without showing anything.I did it very simple:
in c++
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
// QtQuick2ApplicationViewer viewer;
// viewer.setMainQmlFile(QStringLiteral("qml/QMLApplication/main2.qml"));
// viewer.showExpanded();QQmlApplicationEngine engine("qml/QMLApplication/main2.qml"); return app.exec();
}
I qml:
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0Rectangle
{
width: 640
height: 480
Button {
text: qsTr("Hello World")
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
}If I use the commented out viewer it works.
But Id like to use an ApplicationWindow instead of a Rectangle as root item.
Am I missing something or is this just a bug in qt5.1?
Cheers and thx to everyone -
wrote on 21 Jun 2013, 18:03 last edited by
Same problem. No solution yet, sorry.
-
wrote on 21 Jun 2013, 23:11 last edited by
Window and ApplicationWindow is not visible by default. I suspect you simply have to set visible:true in your window definition
-
wrote on 21 Jun 2013, 23:32 last edited by
Ah that did the trick! Quite confusing that it doesn't need it with QtQuick2ApplicationViewer, but never mind.
-
wrote on 31 Jul 2013, 07:49 last edited by
[quote author="Jens" date="1371856261"]Window and ApplicationWindow is not visible by default. I suspect you simply have to set visible:true in your window definition[/quote]
That's just shocking. The examples given for ApplicationWindow e.g. "this example":http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qtquickcontrols-overview.html don't mention this.
-
wrote on 25 Jan 2014, 13:43 last edited by
This just bit me too, can someone add a note to http://qt-project.org/doc/qt-5/qqmlapplicationengine.html that mentions it?
-
Hi,
Can you provide a minimal example for the note ?