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??
-
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:
How can I popup a window in this case??
Place it outside of your ListModel. You can always access it by id.
-
Hi, thanks, but when I try to put a popup outside the ListModel I get a syntax error
ListModel{ // code } Popub{ //code } -
-
Yeah, I mean i typed wrong, but when i write Popup, it still gives syntax error
also for example if I created a Rectangle or Item, and put the Popup outside them it did not recognize the Popup
@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.
-
@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?
-
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!
-
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. -
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