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

Populating qml combobox

$
0
0
How do I populate combobox? I have QStringList model in c++. my main.cpp QGuiApplication app(argc, argv);       QQmlEngine engine;       MainWindowMC mainMC;       engine.rootContext()->setContextProperty("mainMC", &mainMC);     QQmlComponent component(&engine, QUrl::fromLocalFile("qml/convQML/main.qml"));     qDebug() << component.errors();       QQuickWindow* window =  qobject_cast<QQuickWindow*> (component.create());     window->show();       return app.exec(); qml: ComboBox {             id: typebox                   anchors.left: text1.right             anchors.leftMargin: 5                 width: 70             height: 23             anchors.top: parent.top             anchors.topMargin: 37             model: mainMC.typemodel             Component.onCompleted: {               }         } MainWindowMC : class MainWindowMC : public MainM {   //    Q_OBJECT       Q_PROPERTY(QStringList typemodel READ typemodel)     public:       MainWindowMC();       QStringList typemodel();       void typeGenerator();   private:     QStringList m_typemodel;   }; typemodel() is getter function for m_typemodel. How do I port QStringList to qml? And overall, what is the best way to populate qml typebox (or any other model-based component) from c++ model generator?

Viewing all articles
Browse latest Browse all 4972

Trending Articles