QCombobox with key and value
Solved
QML and Qt Quick
-
I using QComboBox design in .qml file and get model from .cpp file.
But I just can set model for ComboBox with QStringList (It work fine). But I want to set model with key and value for ComboBox. Any solution, please give me an advise.ComboBox { id: cboModel Layout.fillWidth: true model: myModel }
My main.cpp
QStringList myModel; // Set data for myModel here. // set to rootContext QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("myModel",QVariant::fromValue(myModel));
-
@tamlong0205
have you read this already? -
@raven-worx . I will try asap and reply here. Thank you very much.
-
I had create a model with key and value and pass it to qml, it worked!!!
Sorry for late reply.
Thank you @raven-worx