Popup in ListModel
-
Hello,
I have a ListModel as shown below:
List.qml
ListModel { property string parentMenu property variant sens: dids.sens //reading data property string title: " LIST " property bool showFunctions: true property variant didsReadOnce: [ "sens", ] ListElement { type: "value" label: "sens" func1value: -128 func1text: "DEFAULT" func3value: -1 func3text: "!minus" func4value: 1 func4text: "!plus" target: "dids.sens" }
in this code i set values manually by buttons for + and -, but i want to popup a window when the value reaches 9 for example.
I tried to add popup but it does not work when I put it in the ListModel like this:
ListModel { //code Popup{ ///code } }
How can I popup a window in this case??
-
@mamoud said in Popup in ListModel:
How can I popup a window in this case??
Place it outside of your ListModel. You can always access it by id.
-
-
@mamoud said in Popup in ListModel:
it still gives syntax error
what error? I you want to get help, paste the exact error that QML engine prints. Otherwise I can only guess.
-
Eh, ok. Does your QML use Window / ApplicationWindow as it's root element? Do you import Controls 2 module, where Popup is located?
-
Ah wait, of course. Your List.qml contains a ListModel element, which you probably assign somewhere else. That is where the popup should be: in the view component, not in the model!
-
No! ListElements are static and cannot have any property changes.
Popup belongs into GUI code, not to model and its data. Somewhere in your code you do have
ListView
, right? That's where your popup needs to be. Or, as another convention has it, you can place it in your main.qml, as a direct child of your Window. -
Rather somewhere beside it
ListView {} Popup {}
-
Do you include the module in qmake?
QT += quickcontrols2