How to disable default button from Dialog
-
wrote on 3 May 2017, 14:16 last edited by
Hey,
I have a simple qml file like this:Item { signal qmlYesSig(string msg) signal qmlNoSig (string msg) Dialog { id: dialog visible: true width:300 height:300 Button { text: "No" onClicked: qmlNoSig("NO") // dialog.close() x:0 y:0 } Button { text: "Yes" onClicked: qmlYesSig("YES") x:0 y:40 } } }
By default it add an "ok" button and i don't know how to remove it.
On the internet i have found something about this but only for controls declare in C++, not for qml.
Is possible to dezactivate the default button? -
Hey,
I have a simple qml file like this:Item { signal qmlYesSig(string msg) signal qmlNoSig (string msg) Dialog { id: dialog visible: true width:300 height:300 Button { text: "No" onClicked: qmlNoSig("NO") // dialog.close() x:0 y:0 } Button { text: "Yes" onClicked: qmlYesSig("YES") x:0 y:40 } } }
By default it add an "ok" button and i don't know how to remove it.
On the internet i have found something about this but only for controls declare in C++, not for qml.
Is possible to dezactivate the default button? -
wrote on 3 May 2017, 21:19 last edited by Eeli K 5 Mar 2017, 21:20
@Lucian The import statements in your qml file reveal what Dialog type you are using. If you open Index in the Qt Creator Help and look for Dialog you get three different Dialog types (in Qt 5.8). It's easier to answer to your question if we know which one of the three Dialogs you are using.
-
wrote on 4 May 2017, 06:27 last edited by
Right, sorry .
Here are my importsimport QtQuick 2.3 import QtQuick.Window 2.0 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.2
-
Right, sorry .
Here are my importsimport QtQuick 2.3 import QtQuick.Window 2.0 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.2
wrote on 4 May 2017, 07:07 last edited by@Adrian.Aioanei Then it's from QtQuick.Dialogs 1.2. Just look at the documentation and the property contentItem. It replaces the whole content, including the default buttons, and you can declare your own buttons. On the other hand the standardButtons property does what you want and maybe more - I don't know why you would want to declare your own "Yes" and "No" buttons and new signals while the standard ones are available.
-
wrote on 4 May 2017, 12:50 last edited by
-
wrote on 4 May 2017, 13:34 last edited by
@Adrian.Aioanei Why it doesn't help to remove the default buttons? "...it is possible to bind contentItem to a custom Item, in which case there will be no buttons, no margins, and the custom content will fill the whole dialog."
-
wrote on 4 May 2017, 15:52 last edited byThis post is deleted!
7/9