Solved How to disable default button from Dialog
-
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? -
@Lucian What are the import statements in your file? There are three different Dialog types in QML.
-
Hey @Eeli-K ,
I'm sorry but i didn't understand your question :D -
@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.
-
Right, sorry .
Here are my importsimport QtQuick 2.3 import QtQuick.Window 2.0 import QtQuick.Controls 1.2 import QtQuick.Dialogs 1.2
-
@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.
-
-
@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."
-
This post is deleted!