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

Popup a component in qml



  • Hi ,

    I have a component "redSquare" and a rectangle "rect" in main file. rect is visible and on click on the rect the redsquare should pop up.

    I have been spending time on pop up help and not able to find any suitable example that uses given component in it .

    So my question is how to use component in such a manner that given component pops up on a click in rectangle , square shaped any other component.

        Component {
                id: redSquare
    
                Rectangle {
                    color: "red"
                    width: 100
                    height: 100
                }
            }
    
    
    
        Popup {
            id: pp
           
            modal: true
            focus: true
            closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
    
        }
    
            Rectangle {
                        id: rect
                        x: 710
                        y: 10
                        width: 80
                        height: 80
                        radius: 10
                        color: "#ffffff"
                        visible: true
            
                        MouseArea {
                            id: it
                            anchors.fill: parent
                            onClicked: {
                           //     pp.component = redSquare
                                pp.open()
                            }
                        }
                    }
    

Log in to reply