I need help with implementing a date picker



  • Hello, I can implement simple calendar but in my form I don't found how to insert the selected date...

    I'm using QtQuick.Localstorage, then the date have to be insert in sqlite
    Could you help me?...

    Item {
        id: input
        
        height: Screen.height / 2
        
        function insertrec() {
            var rowid = parseInt(JS2.dbInsert(dateconstructionInput.text), 10)
            if (rowid) {
                listView.model.setProperty(listView.currentIndex, "id", rowid)
                listView.forceLayout()
            }
            return rowid;
        }
        function editrec(Pdateconstruction,  Prowid) {
            dateconstructionInput.text = Pdateconstruction
        }
        function initrec() {
            dateconstructionInput.clear()   
        }               
        function setlistview() {
            
            listView.model.setProperty(listView.currentIndex, "dateconstruction",
                                       dateconstructionInput.text)
        }
        Rectangle {
            id: rootrect
            ColumnLayout {
                id: mainLayout
                anchors.fill: parent
                anchors.leftMargin: 10
                
                Rectangle {
                    id: gridBox
                    Layout.fillWidth: true
                    GridLayout {
                        id: gridLayout
                        y: 60
                        rows: 10
                        flow: GridLayout.TopToBottom
                        anchors.fill: parent
                        
                        Text {
                            text: "date de construction"
                            font.pixelSize: 22
                            rightPadding: 10
                        }
                        TextInput {
                            id: dateconstructionInput
                            font.pixelSize: 22
                            activeFocusOnPress: true
                            activeFocusOnTab: true
                            onEditingFinished: {
                                if (dateconstructionInput.text == "") {
                                    statustext.text = "Please fill in the date"
                                    dateconstructionInput.forceActiveFocus()
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    

    Thanks a lot for your help!

    [Edit: fixed code layout ~~ @Wieland]



  • Hi! Your question seems pretty vague to me. Can you please clarify what's your problem exactly?



  • Hello, I need to know how in qml I can send the selected date from calendar to my dateconstruction to save it in my sqlite table

    thank you very much


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.