Important: Please read the 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


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

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

    what failed with this ?

  • @LeLev ```
    property alias mydelayButton: mydelayButton


       mydelayButton:"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(){
               = false
                        console.log(qsTr("Button pressed"))
               = true
                        console.log(qsTr("Button RELEASED"))
                function enableCmd(){
                        groupBox1.enabled = true
                        console.log(qsTr("group box enabled"))
                        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?


Log in to reply