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. GridView data
QtWS25 Last Chance

GridView data

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 874 Views
  • 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.
  • J Offline
    J Offline
    JasonS
    wrote on last edited by p3c0
    #1

    This is probably QML 101, but I'm having difficulties figuring out how to iterate through or even get values from a GridView. I have a 7x3 GridView made up of delegate I made:

    import QtQuick 2.0
    
    Item{
        id: scheduleDelegate
    
        property string name
        signal trigger(string name)
    
        Column{
            spacing: 5
    
            Text{
                id: columnHeading
                width: 35
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                text: "Wk " + (index + 1)
            }
    
            TextEditNumberInput{
                id: bloom
                textToShow: text1
                }
            }
    
            TextEditNumberInput{
                id: big
                textToShow: text2            
                }
            }
    
            TextEditNumberInput{
                id: tiger
                textToShow: text3            
                }
            }
        }
    }
    

    TextEditNumberInput is as follows:

    import QtQuick 2.0
    import QtQuick.Controls 2.0
    import QtQuick.Layouts 1.3
    
    TextField{
        id: number
    
        property alias textToShow: number.text
    
        width: 35
        height: 35
    
        Layout.fillHeight: true
        Layout.fillWidth: true
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
        padding: 0
    
        text: text
    
        background: Rectangle {
            border.color: "#D3D3D3"
            border.width: 1
            anchors.fill: parent
        }
    
        NumberPad{
            id: numberPad
        }
    
        MouseArea {
            anchors.fill: parent
            onClicked: {
                numberPad.x = (width / 5 - numberPad.width / 5 )
                numberPad.y = (height / 2 - numberPad.height / 2)
    
                var numberPadComponent = Qt.createComponent("qrc:/pages/NumberPad.qml");
                if (numberPadComponent.status === Component.Ready) {
                    var dialog = numberPadComponent.createObject(parent);
    
                    numberPad.open()
                }
            }
        }
    
        Connections {
            id: numberPadConnection
            target: numberPad
    
            onVisibleChanged: {
                if(!target.visible){
                    if(!target.returnValue==""){
                        setNumberOfWeeksText();
                    }
                }
            }
    
            function setNumberOfWeeksText(){
                number.text = target.returnValue;
            }
        }
    }
    

    Can someone help explain to me how to get the values from the TextField within my GridView?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      peteritv
      wrote on last edited by
      #2

      Since you define a scheduleDelegate signal:
      signal trigger(string name)

      You need to bind some action of your TextEditNumberInput component to that signal?

      So something inside your TextField like:
      onChanged: { trigger(text) }

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JasonS
        wrote on last edited by
        #3

        Thanks, that helped me solve my question.

        P 1 Reply Last reply
        0
        • J JasonS

          Thanks, that helped me solve my question.

          P Offline
          P Offline
          peteritv
          wrote on last edited by
          #4

          @JasonS : Ur welcome! I am just starting QML myself, and us newbies should support eachother :)

          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