[Solved] QDialog not display



  • If I close QDialog from hitting the window managers close button on linux I am unable to display it again. This is not ture if I close it with QDialog button. This is on Linux with Qt 5.3.1. Does any one know the secret sause to make dialog reappear (Note this is a standard model dialog)

    Here is my code to show the dialog:

    @console.log("SHOW Server Confilg Dialog");
    mydialog.open();
    mydialog.visible = true;@

    I always get the console messge but not the dialog

    Thanks in aadvance for any help


  • Lifetime Qt Champion

    Hi,

    Do you have something like

    @
    void showMyCoolDialog()
    {
    MyDialog mydialog;
    console.log("SHOW Server Confilg Dialog");
    mydialog.open();
    mydialog.visible = true;
    }
    @

    ?

    If so, your dialog is destroyed at the end of the function.



  • No, I have it as written the declaration is outside the call. But even if I did why would it not create a new instance.

    This is rather strange behavior if you ask me,


  • Lifetime Qt Champion

    What is your exact code ?



  • @ApplicationWindow {
    id: mainwindow
    title: "FixHarness"
    visible: true
    width:600
    height:600
    property bool connectedToServer:false
    Dialog {
    id:mydialog
    visible:false
    title: "Blue sky dialog"
    standardButtons: StandardButton.Save | StandardButton.Cancel
    }

    function showServerConfigDialog()
    {
        console.log("SHOW Server Confilg Dialog");
        mydialog.open();
        mydialog.visible = true;
    }
    

    Action {
    id:configureServerA
    text: qsTr("Configure")
    iconSource: "qrc:/images/32x32/config.png"
    iconName: "configure"
    tooltip: "Server settings"
    onTriggered: {
    console.log("SHOW SERVER....");
    mainwindow.showServerConfigDialog();
    }
    }
    }
    @



  • Try this. I don't really understand your problem.

    @import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtQuick.Dialogs 1.2

    ApplicationWindow {
    id:root
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    menuBar: MenuBar {
        Menu {
            title: qsTr("File")
            MenuItem {
                text: qsTr("&Open")
                onTriggered: {
                    console.log("Open action triggered");
                    showServerConfigDialog();
    
                }
            }
            MenuItem {
                text: qsTr("Exit")
                onTriggered: Qt.quit();
            }
        }
    }
    
    Text {
        id:textHW
        text: qsTr("Click me to open server dialog")
        anchors.centerIn: parent
        MouseArea {
            anchors.fill: parent
            onClicked: showServerConfigDialog()
        }
    }
    
    Dialog {
        width: 350
        height: 200
        id:mydialog
        visible:false
        title: "Server dialog"
    
        Text {
            id: dialogText
            text: qsTr("Server dialog")
        }
    
    
    
        standardButtons: StandardButton.Save |  StandardButton.Cancel
        onAccepted: {
            console.log("Save server dialog");
            root.title = qsTr("Save server dialog");
        }
        onRejected: {
            console.log("Cancel server dialog");
            root.title = qsTr("Cancel server dialog");
        }
    }
    
    
    function showServerConfigDialog() {
        console.log("Show server dialog");
        mydialog.open();
    }
    

    }

    @



  • Hi

    I have some issue related to this. If I change the code from previous to the following. When I clicked on OK button I got immediately console.log ("Save server dialog"); but textHw. text changed after I moved the mouse. If I clicked on textHw the textHw.text changed immediately to "Change text".
    There is also some issue that menu bar disappearing during window resize.

    I modify
    @
    // onClicked: showServerConfigDialog()
    onClicked: textHW.text = qsTr("Change text");
    @

    and

    @ standardButtons: StandardButton.Save | StandardButton.Cancel
    onAccepted: {
    console.log("Save server dialog");
    textHW.text = qsTr("Save server dialog");
    root.title = qsTr("Save server dialog");
    }
    onRejected: {
    console.log("Cancel server dialog");
    textHW.text = qsTr("Cancel server dialog");
    root.title = qsTr("Cancel server dialog");
    }@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.