Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.
Modal Dialog with Qt Components on Meego: Difference between revisions
No edit summary |
AutoSpider (talk | contribs) (Remove inaccurate statement about Maemo/MeeGo successor. See Talk:Support for Maemo) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:snippets]] | {{Outdated|reason=The MeeGo/Harmattan platform is no longer supported.}} | ||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | |||
[[Category:snippets]] | |||
[[Category:HowTo]] | |||
'''English''' [[Modal_Dialog_with_Qt_Components_on_Meego_Bulgarian|Български]] | '''English''' [[Modal_Dialog_with_Qt_Components_on_Meego_Bulgarian|Български]] | ||
Line 5: | Line 9: | ||
= How to make a Modal Dialog with Qt Components on MeeGo = | = How to make a Modal Dialog with Qt Components on MeeGo = | ||
There is a | There is a [http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-dialog.html?tab=1 QML Dialog element] in Qt Quick Components in MeeGo 1.2 Harmattan API. But this dialog is not modal - i.e. it can be closed by pressing on any part of the dialog's window, not only on the buttons. Such behavior is not good in some cases - any accidental touch can close the dialog's window. There is no way through the API to make this dialog not respond on background clicks. | ||
Surely we can make such a window ourselves without using Dialog element, but it is not a quick or proper way. | Surely we can make such a window ourselves without using Dialog element, but it is not a quick or proper way. | ||
From the Dialog's source it can be discovered that a background click generates a '''privateClicked''' signal. Let's disable it by adding 2 lines into Dialog's creation: | From the Dialog's source it can be discovered that a background click generates a '''privateClicked''' signal. Let's disable it by adding 2 lines into Dialog's creation: | ||
<code> | |||
signal privateClicked | |||
onPrivateClicked: {} | |||
</code> | |||
and we get truly modal dialog. | |||
'''Full example of page with dialog''' | '''Full example of page with dialog''' | ||
<code> | |||
import QtQuick 1.1 | |||
import com.nokia.meego 1.0 | |||
Page { | Page { | ||
QueryDialog { | QueryDialog { | ||
id: quDialog | |||
signal privateClicked | |||
onPrivateClicked: {} | |||
anchors.centerIn: parent | |||
titleText: "Modal Dialog" | |||
rejectButtonText: "Cancel" | |||
onRejected: { console.log ("Rejected");} | |||
} | |||
Component.onCompleted: quDialog.open() | |||
} |
Latest revision as of 15:06, 27 April 2015
IMPORTANT: The content of this page is outdated. Reason: The MeeGo/Harmattan platform is no longer supported. If you have checked or updated this page and found the content to be suitable, please remove this notice. |
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
English Български
How to make a Modal Dialog with Qt Components on MeeGo
There is a QML Dialog element in Qt Quick Components in MeeGo 1.2 Harmattan API. But this dialog is not modal - i.e. it can be closed by pressing on any part of the dialog's window, not only on the buttons. Such behavior is not good in some cases - any accidental touch can close the dialog's window. There is no way through the API to make this dialog not respond on background clicks.
Surely we can make such a window ourselves without using Dialog element, but it is not a quick or proper way.
From the Dialog's source it can be discovered that a background click generates a privateClicked signal. Let's disable it by adding 2 lines into Dialog's creation:
signal privateClicked
onPrivateClicked: {}
and we get truly modal dialog.
Full example of page with dialog
import QtQuick 1.1
import com.nokia.meego 1.0
Page {
QueryDialog {
id: quDialog
signal privateClicked
onPrivateClicked: {}
anchors.centerIn: parent
titleText: "Modal Dialog"
rejectButtonText: "Cancel"
onRejected: { console.log ("Rejected");}
}
Component.onCompleted: quDialog.open()
}