Modal Dialog with Qt Components on Meego: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[Modal Dialog with Qt Components on Meego Bulgarian|Български]]
[[Category:snippets]]<br />[[Category:HowTo]]


=How to make a Modal Dialog with Qt Components on MeeGo=
'''English''' [[Modal_Dialog_with_Qt_Components_on_Meego_Bulgarian|Български]]


There is a [http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-dialog.html?tab=1 <span class="caps">QML</span> Dialog element] ''[harmattan-dev.nokia.com]'' in Qt Quick Components in MeeGo 1.2 Harmattan <span class="caps">API</span>. 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 <span class="caps">API</span> to make this dialog not respond on background clicks.
= How to make a Modal Dialog with Qt Components on MeeGo =
 
There is a &quot;QML Dialog element&amp;quot;:http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-dialog.html?tab=1 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: <br /> and we get truly modal dialog.
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:<br /><code><br /> signal privateClicked<br /> onPrivateClicked: {}<br /></code><br />and we get truly modal dialog.


'''Full example of page with dialog'''<br />
'''Full example of page with dialog'''<br /><code><br />import QtQuick 1.1<br />import com.nokia.meego 1.0


===Categories:===
Page {


* [[:Category:HowTo|HowTo]]
QueryDialog {<br /> id: quDialog<br /> signal privateClicked<br /> onPrivateClicked: {}<br /> anchors.centerIn: parent<br /> titleText: &quot;Modal Dialog&amp;quot;<br /> rejectButtonText: &quot;Cancel&amp;quot;<br /> onRejected: { console.log (&quot;Rejected&amp;quot;);}<br /> }<br /> Component.onCompleted: quDialog.open()<br />}
* [[:Category:snippets|snippets]]

Revision as of 11:14, 24 February 2015


English Български

How to make a Modal Dialog with Qt Components on MeeGo

There is a "QML Dialog element&quot;:http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-dialog.html?tab=1 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:

<br /> signal privateClicked<br /> onPrivateClicked: {}<br />


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&quot;
rejectButtonText: "Cancel&quot;
onRejected: { console.log ("Rejected&quot;);}
}
Component.onCompleted: quDialog.open()
}