samedi 8 août 2015

Change the display of a message box based upon if a checkbox is checked or not in Qt5

Okay, so I have started to learn Qt5. I do have some c++ background. Playing around with the text editor code example, I added a checkbox and named it ckbox. Under the menu I added a new item that when clicked I want it to check the state of the check box and display a message box with a message. A different one for each state of the checkbox. I get and error stating "ReferenceError: ckbox is not defined". Here is the code for the menuitem:

MenuItem {
            text: qsTr("&Message")
            onTriggered: if (ckbox.isChecked === True) {
                             messageDialog.show(qsTr("If a witch floats,"))
                         } else {
                             messageDialog.show(qsTr("therefore she is made of wood."))
                         }
        }

Thanks in advance for your help!




Aucun commentaire:

Enregistrer un commentaire