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

How to load Popup component from other .qml



  • I'm trying to make popup function on QML, but it didn't work.

    Firstly, I made main.qml and put a button to open a popup window. If I put the Popup component in the same .qml file, it worked well. But I want to separate components to modify easily.

    [main.qml]

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    
    Window {
        width: 1024
        height: 720
        visible: true
        title: qsTr("Hello World")
    
        Button {
            id: btn_Crop_Template
            x: 31
            y: 237
            width: 170
            height: 50
            text: qsTr("Crop Template")
            onClicked: popup.open()
        }
    }
    
    

    [imgproc_popup.qml]

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.12
    
    Popup {
            id: popup
            x: 100
            y: 100
            width: 1000
            height: 500
            modal: true
            focus: true
    
            closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
        }
    
    

    How can I load the popup window?




Log in to reply