Ok, I'm learning how to work with QML, and I have one doubt. In my example, I have a ListModel with ListElements in QML, and I have a main QML file with a rectangle, PathView, etc.
I also have a QWidget than my main window. In this QWidget, I include the QML interface as a component. Ok!
How can I handle QML ListElements using C ++?
Note: when I say "process", I want to say, for example, include an element.
Below are some parts of my code ...
QML containing my ListElement called "Menu1":
import QtQuick 1.0 ListModel { id: listMovieModel ListElement { name: "Image 1"; iconSource: "pics/image_1.jpg" } ListElement { name: "Image 2"; iconSource: "pics/image_2.jpg" } ListElement { name: "Image 3"; iconSource: "pics/image_3.jpg" } ListElement { name: "Image 4"; iconSource: "pics/image_4.jpg" } ListElement { name: "Image 5"; iconSource: "pics/image_5.jpg" } ListElement { name: "Image 6"; iconSource: "pics/image_6.jpg" } }
My main QML:
Rectangle { width: 500 height: 600 color: "transparent" PathView { id: view focus: true width: parent.width height: parent.height + y y: -150 model: Menu1 {}
And since I use QML as a component for my QWidget:
MainForm::MainForm(QWidget *parent) : QWidget(parent), ui(new Ui::MainForm) { ui->setupUi(this); this->resize(1024, 576); QDeclarativeView *myQMLTest = new QDeclarativeView(QUrl::fromLocalFile("myMainQML.qml")); myQMLTest->setStyleSheet(QString("background: transparent; width: 600px")); this->ui->frameListVideoGallery->layout()->addWidget(myQMLTest); myQMLTest->setFocus(); myQMLTest->installEventFilter(this); }
I have seen some articles about this, but I cannot change my LisModel using C ++. I saw here http://doc.qt.nokia.com/4.7/qdeclarativemodels.html#c-data-models and here in the examples using PathView http://doc.qt.nokia.com/4.7/qdeclarativeexamples.html
Can someone help me?
Thanks!
source share