0

I'm working on my project and I've got a problem with C++/QML data interaction. I need to make an information exchange between views: List->Project's details. Currently I'm using QAbstractModel object as a C++ model, but recently I understood that I need to use properties in my model.

E.g. string myId, which I could use to exchange data between views.

    ListModel {
    property string myId: ""
    title:"abc"
    isActive:true
...
    }

I need to add such variable property string to my model from C++ code. Is there any opportunity to add a property string in C++?

I've used a StockQt example's idea how to make a "template" page, which demonstrates stock's information. But I need to fill the model from C++ and then use it as a model for the project's list and view of each project in details. In details, I have a list of projects, e.g.:

  • Project A
  • Project B
  • Project C

and then I want to click on the project's name and look at details of this project on a different View. I see that I could make it by properties of the model, because a StockQt's example shows that it's possible, but I can't understand how to fill these properties by C++.

Details: I have a main ListView as a Master-flow menu. Then, when you click on menu item, you can see an another ListView, which shows list of projects. Then I'd like to click on the project's name and see a details page.

Help me please to resolve this problem!

Luno
  • 35
  • 8
  • 1
    What you ask is unclear, and you seem to have gotten the wrong impressions. Improve your question to illustrate your actual intent so you can be given an adequate answer how to achieve it. – dtech Mar 22 '17 at 21:55
  • Still unclear, you don't need anything extra to exchange data between views, that's the model's responsibility. – dtech Mar 22 '17 at 23:15
  • I'm sorry, I was so impressed by my failure that I thought that I've provided enough information. :( – Luno Mar 22 '17 at 23:28
  • http://stackoverflow.com/a/42569514/991484 – dtech Mar 22 '17 at 23:43
  • Unfortunately, it'sn't what I'm looking for. I'll try to add more details – Luno Mar 23 '17 at 12:04
  • You are asking several things that takes different steps to do. I'd recommend going over how model view works in Qt. C++ will hold your data, and QML will display it. You have to know how your data will be arranged (C++ containers) and in what view you will display it (QML TableView). – Francisco Hernandez Jul 22 '17 at 05:51

0 Answers0