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

Dialog window close when opening another dialog inside



  • Hello,
    I'm working on a QML application. My problem is that when i open another dialog in a dialog window, my window close automatically. I'm using qml Dialog component.
    Can anyone help?


  • Moderators

    Hi @Babs

    do you have a minimal reproducible example at hand ?



  • @J-Hilk here is my code i create a first dialog to a toolBar button.

                    Loader{
                        id:dlgLoader
                        sourceComponent: diaComp
                        active: false
                    }
                    Component{
                        id:diaComp
                        Dialog{
                            id:dialogplan
                            width: paneldev.implicitWidth
                            height: paneldev.implicitHeight
    
                            title:"Planning"
                            standardButtons: Dialog.Ok | Dialog.Cancel
    
                            onAccepted:{
                                plan.addToDatabase();
                                dialogplan.close()
                            }
                            onRejected: {
                            }
                            PanelContainer{
                                id:paneldev
                                anchors.fill: parent
                                resizable: false
                                detachable: false
                                collapsable: false
                                size: Style.realPixels(640)
    
                                TabView{
                                    id:tabView
                                    anchors.fill: parent
                                    anchors.margins: 2
                                    tabPosition: Qt.TopEdge
    
                                    Layout.minimumWidth: 360
                                    Layout.minimumHeight: 360
                                    Layout.preferredWidth: 480
                                    Layout.preferredHeight: 640
    
    
                                    Tab{
                                        title: "Parameters setting"
    
                                        PagePlannification{
    
                                        }
                                    }
    
                                    Tab{
                                        title: "Equipement"
                                    }
    
                                    Tab{
                                        title: "Planning"
                                        Planning{
    
                                        }
    
                                    }
    
                                    style: TabViewStyle {
                                        frameOverlap: 1
                                        tab: Rectangle {
                                            color: styleData.selected ? "gray" :"white"
                                            border.color:  "black"
                                            implicitWidth: Math.max(text.width + 4, 80)
                                            implicitHeight: 20
                                            radius: 2
                                            Text {
                                                id: text
                                                anchors.centerIn: parent
                                                text: styleData.title
                                                color: styleData.selected ? "white" : "black"
                                            }
                                        }
                                        frame: Rectangle { color: "white" }
                                    }
                                }
                            }
                        }
                    }
    

    And inside that dialog i create the following one. The problem is when i open it, my first dialog window close automatically.

                    Dialog{
                        id:dialogPaliers
                        width: 640
                        height: 480
    
                        title:qsTr("Sélectionner les paliers")
    
                        standardButtons: Dialog.Ok | Dialog.Cancel
                        onAccepted: dialogPaliers.close()
                        PanelContainer{
                            anchors.fill: parent
                            id:paneldev
                            size: Style.realPixels(300)
                            resizable: false
                            detachable: false
                            collapsable: false
    
                            Rectangle{
                                anchors.fill: parent
                                color: "#ffffff"
    
                                ScrollView{
                                    anchors.fill:parent
                                    StretchColumnContainer{
                                        id:container
                                        spacing: 20
                                        anchors.top: parent.top
                                        anchors.topMargin: spacing
                                        Repeater{
                                            id:rep
                                            model:spinNumSteps.value
                                            StretchRowContainer{
                                                spacing: 200
                                                TextLabel {
    
                                                    text: qsTr("Saisr la valeur du  palier " + (index+1))
                                                }
                                                SpinBox{
                                                    id:spinPal
                                                    minimumValue: 0
                                                    maximumValue: 10000
                                                    decimals: 2
                                                    onEditingFinished:  {
                                                        plan.addValue(spinPal.value,index)
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
    

Log in to reply