Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Popup in ListModel

Popup in ListModel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
17 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mamoudM Offline
    mamoudM Offline
    mamoud
    wrote on last edited by mamoud
    #1

    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??

    sierdzioS 1 Reply Last reply
    0
    • mamoudM mamoud

      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??

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @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.

      (Z(:^

      mamoudM 1 Reply Last reply
      0
      • sierdzioS sierdzio

        @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.

        mamoudM Offline
        mamoudM Offline
        mamoud
        wrote on last edited by mamoud
        #3

        @sierdzio

        Hi, thanks, but when I try to put a popup outside the ListModel I get a syntax error

        ListModel{
        // code
        }
        
        Popub{
        //code
        }
        
        
        sierdzioS 1 Reply Last reply
        0
        • mamoudM mamoud

          @sierdzio

          Hi, thanks, but when I try to put a popup outside the ListModel I get a syntax error

          ListModel{
          // code
          }
          
          Popub{
          //code
          }
          
          
          sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          @mamoud said in Popup in ListModel:

          Popub{

          Typo :-)

          What syntax error?

          (Z(:^

          mamoudM 1 Reply Last reply
          0
          • sierdzioS sierdzio

            @mamoud said in Popup in ListModel:

            Popub{

            Typo :-)

            What syntax error?

            mamoudM Offline
            mamoudM Offline
            mamoud
            wrote on last edited by
            #5

            @sierdzio

            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

            sierdzioS 1 Reply Last reply
            0
            • mamoudM mamoud

              @sierdzio

              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

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @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.

              (Z(:^

              mamoudM 1 Reply Last reply
              0
              • sierdzioS sierdzio

                @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.

                mamoudM Offline
                mamoudM Offline
                mamoud
                wrote on last edited by mamoud
                #7

                @sierdzio

                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

                1 Reply Last reply
                0
                • sierdzioS Offline
                  sierdzioS Offline
                  sierdzio
                  Moderators
                  wrote on last edited by
                  #8

                  Eh, ok. Does your QML use Window / ApplicationWindow as it's root element? Do you import Controls 2 module, where Popup is located?

                  (Z(:^

                  mamoudM 1 Reply Last reply
                  0
                  • sierdzioS sierdzio

                    Eh, ok. Does your QML use Window / ApplicationWindow as it's root element? Do you import Controls 2 module, where Popup is located?

                    mamoudM Offline
                    mamoudM Offline
                    mamoud
                    wrote on last edited by
                    #9

                    @sierdzio

                    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

                    1 Reply Last reply
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #10

                      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!

                      (Z(:^

                      mamoudM 1 Reply Last reply
                      2
                      • sierdzioS sierdzio

                        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!

                        mamoudM Offline
                        mamoudM Offline
                        mamoud
                        wrote on last edited by mamoud
                        #11

                        @sierdzio
                        so should i create the popup object in ListElemnt

                        1 Reply Last reply
                        0
                        • sierdzioS Offline
                          sierdzioS Offline
                          sierdzio
                          Moderators
                          wrote on last edited by
                          #12

                          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.

                          (Z(:^

                          mamoudM 1 Reply Last reply
                          0
                          • sierdzioS sierdzio

                            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.

                            mamoudM Offline
                            mamoudM Offline
                            mamoud
                            wrote on last edited by
                            #13

                            @sierdzio

                            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{
                            
                            }
                            
                            }
                            
                            1 Reply Last reply
                            0
                            • sierdzioS Offline
                              sierdzioS Offline
                              sierdzio
                              Moderators
                              wrote on last edited by
                              #14

                              Rather somewhere beside it

                              ListView {}
                              Popup {}
                              

                              (Z(:^

                              mamoudM 1 Reply Last reply
                              0
                              • sierdzioS sierdzio

                                Rather somewhere beside it

                                ListView {}
                                Popup {}
                                
                                mamoudM Offline
                                mamoudM Offline
                                mamoud
                                wrote on last edited by mamoud
                                #15

                                @sierdzio
                                Thank you for your help, but i still have the same problem :(
                                when i put popup outside ListModel , i get syntax error

                                1 Reply Last reply
                                0
                                • sierdzioS Offline
                                  sierdzioS Offline
                                  sierdzio
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  Do you include the module in qmake?

                                  QT += quickcontrols2
                                  

                                  (Z(:^

                                  mamoudM 1 Reply Last reply
                                  0
                                  • sierdzioS sierdzio

                                    Do you include the module in qmake?

                                    QT += quickcontrols2
                                    
                                    mamoudM Offline
                                    mamoudM Offline
                                    mamoud
                                    wrote on last edited by
                                    #17

                                    @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

                                    1 Reply Last reply
                                    0

                                    • Login

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • Users
                                    • Groups
                                    • Search
                                    • Get Qt Extensions
                                    • Unsolved