Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ui.qml -> qml actions



  • I'm beginner in qt quick world ... inside a swipeWiev i have a layout with row and column with some delay button and statusindicator like these (myfile.ui.qml):

    /* gui ui.qml file */
                                Column {
                                    id: column
                                    spacing: 15
    
                                    
                                    DelayButton {
                                        id: onDelBnt1
                                        x: 0
                                        width: 100
                                        height: 100
                                        text: qsTr("press the button!")
    
    
                                    }
    
                                    StatusIndicator {
                                        id: statusIndicator
                                        x: 34
                                        width: 34
                                        height: 34
                                        color: "#0f8241"
    
                                    }
    
    
    
                                }
    

    javascript block is not enabled in ui file, and not understand how i can insert the function on myMain.qml file .... I tru property alias mechanism but fail .....
    I want to press the button and after delay put in on state the status indicator ..... is quite simple but never try ....
    I'm on qt5.11 qtquick.control2

    regards



  • hi
    @gfxx said in ui.qml -> qml actions:

    I tru property alias mechanism but fail .....

    what failed with this https://doc.qt.io/qtcreator/creator-quick-ui-forms.html ?



  • @LeLev ```
    /ui.qml/
    page{
    x:10
    y:10
    property alias mydelayButton: mydelayButton
    .......

    /mymain.qml/

       mydelayButton: messageDialog.show(qsTr("Button pressed"))  
    
    
    the debugger said: error! mybutton alias read only property


  • ok ok ... from ui.qml file in design mode (opposite to text mode)

    • hover the component
    • right click on mouse
    • menĂ¹ "go to implementation" or " new signal handler"

    than in main.qml file, somethings like these:

                function changePos(){
                    if(delayBnt1.checked){
                        statusIndicator.active = false
                        console.log(qsTr("Button pressed"))
                    }
                    else{
                        statusIndicator.active = true
                        console.log(qsTr("Button RELEASED"))
                    }
    
                }
    
                function enableCmd(){
                    if(togBtn.checked){
                        groupBox1.enabled = true
                        console.log(qsTr("group box enabled"))
                    }
                    else{
                        groupBox1.enabled = false
                        console.log(qsTr("group box DISABLE"))
                    }
                }
    
                delayBnt1.onCheckedChanged: changePos()
                togBtn.onCheckedChanged: enableCmd()
    

    There is a way to do these with less rows of code?

    regards


Log in to reply