Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

[Solved] Setting model from C++ does not work on Androd ...

$
0
0
… but it does work on Desktop Ok, I am using Qt 5.4.1 (the latest) If I try to set a string list model from C++ it fails on actual Android device (Nexus 5), The screen is just black. However the same code runs fine on my Ubuntu Desktop. Here is my code: int main(int argc, char *argv[]) {     QStringListModel myModel;     QApplication app(argc, argv);     QQmlApplicationEngine engine;     QStringList list;     list << "one" << "two" << "three" << "four";     myModel.setStringList(list);     engine.rootContext()->setContextProperty("myModel", &myModel);     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));     QObject *topLevel = engine.rootObjects().value(0);     QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);     window->show();     return app.exec(); } main.qml … Rectangle {         id: buttonArea         color:"red"         anchors.fill: parent         GridView {             width: 300; height: 200             cellHeight: 100             cellWidth: 100             id: gView;             model: myModel;             delegate: buttonDelegate             anchors.fill: parent         }     } ... } Any idea as to why this fails on Andoid ? Thank for any help here, David

Viewing all articles
Browse latest Browse all 4972

Trending Articles