Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Manage QML pages from c++
I'm starting a new Qt Quick application and I would like to control QML pages (items) from a class c++.
Let me explain, I would like to develop a model-view-controller application with the model and controller in c++ and only the view in QML.
But I don't know what's the best way to do it.
In the past I used QWidget : I put all my QWidget pages in a QStackedLayout and I changed the current index to switch between pages. And I would like to reproduce this mechanism but with QML pages.
Have you done that before ?
Can you help me to design my application ?
Good. You can do all that. Just check SwipeView component.
Ok, I also saw StackLayout in QML, I think I can use it.
But how can I change the currentIndex of this QML component in c++ ?
I mean, what is the best way ?
Best way is to make it declarative. You can define currentIndex as Q_PROPERTY inside the QObject class and expose it.
Ok great, thanks for your help !
Just another question, I have a big database (around 100 variables). Is it safe to use 100 Q_PROPERTY ? To use the database from QML.
I suggest you to close this issue and open another issue. So that it helps others who are looking for similar question.