Unsolved 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.
-
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.
-
it just says Syntax error, when I run the program. showing Popup with arrow pointing up and says Syntax error.
When i put the Popup inside ListModel, it gives no errors
-
Eh, ok. Does your QML use Window / ApplicationWindow as it's root element? Do you import Controls 2 module, where Popup is located?
-
Yeah I imported Control 2 like this:
import QtQuick.Controls 2.4
and my Popup located in a different folder but i imported it also -
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!
-
@sierdzio
so should i create the popup object in ListElemnt -
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. -
yeah right, I have a qml file called ItemView.qml
in this file there is an object called ListView, should I put the popup inside this object ListView like this:
ListView{ popup{ } }
-
Rather somewhere beside it
ListView {} Popup {}
-
@sierdzio
Thank you for your help, but i still have the same problem :(
when i put popup outside ListModel , i get syntax error -
Do you include the module in qmake?
QT += quickcontrols2
-
@sierdzio
Hi, I tried different ways to solve this, but unfortunately did not work. Is there anyway instead of popups to show that, the value of "Senstivity" exceeded a specific value