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

qml sequential



  • Hello All,
    The following are two python classes called by qml file. I want to make the first class implement first when condition is True and after it finish the second class start. How to make this in qml (in another meaning running two statements sequentially) 93d787d6-f36e-46e2-bfed-3c3440a3f2f0-image.png



  • @Abdulrahman Your question is not clear so you must give more details in addition to providing a minimal and verifiable example



  • hi

    @Abdulrahman said in qml sequential:

    and after it finish the second class start

    Add a signal to your first class and call it within the method
    Connect that signal to second class method
    https://wiki.qt.io/Qt_for_Python_Signals_and_Slots



  • @LeLev the first class inside if condition so it will not be called all the time but the second class will be. So adding signal will help when first class be called but when it is not, it will not.



  • @eyllanesc In qml how to prevent red rectangle from showing except after Ok button inside the dialog clicked and if the dialog didn't open(due to not achieving the condition) the red rectangle shows(making block of the code goes sequential instead of parallel)

    2bfee7cb-9105-4f9f-93a7-d2d5a6917e95-image.png

    Code for main Window:

    import QtQuick 2.13
    import QtQuick.Window 2.13
    import QtQuick.Controls 2.0
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
        SaveDialog{id: save}
        onXChanged: {
            save.open()
        }
        Rectangle{
            width: 200
            height: 200
            color: 'red'
            Text {
                text: qsTr("Two")
            }
        }
    }
    
    

    Code for The Dialog:

    import QtQuick 2.12
    import QtQuick.Layouts 1.12
    import QtQuick.Dialogs 1.2
    import QtQuick.Controls 2.0
    
    Dialog{
        id: dialog
        width: 200
        height: 100
        title: "One"
    }
    
    


  • @Abdulrahman Use the accepted signal:

    import QtQuick 2.13
    import QtQuick.Controls 2.0
    import QtQuick.Window 2.13
    
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
        onXChanged: function() {
            save.open();
        }
    
        SaveDialog {
            id: save
    
            onAccepted: function() {
                rect.visible = true;
            }
        }
    
        Rectangle {
            id: rect
    
            width: 200
            height: 200
            color: 'red'
            visible: false
    
            Text {
                text: qsTr("Two")
            }
    
        }
    
    }
    

Log in to reply