[Qt-qml] Modal dialogs in QML?
Girish Ramakrishnan
girish at forwardbias.in
Wed Nov 24 12:37:42 CET 2010
Hi,
On Wed, Nov 24, 2010 at 10:05 AM, Bart Kelsey <elbarto at gmail.com> wrote:
> Greets!
>
> Is there any way to create a modal dialog in QML, such that mouse input
> outside of the dialog box is blocked? I've tried making a dialog with a
> MouseArea under it (which would catch mouse input and do nothing with it),
> but I can't seem to figure out how to make the MouseArea fill the entire
> screen. Any ideas?
>
Conceptually something like,
// main.qml
Item {
....
Dialog { // make Dialog a direct child of the main window
anchors.fill: parent; // Dialog spans the entire window
MouseArea { anchors.fill: parent; onClicked: opacity = 0; } //
handle outside clicks
Rectangle { // the dialogs content
anchors.centerIn: parent
MouseArea { anchors.fill: parent; } // absorb clicks in
the "content" area so that it won't close the dialog
...your dialog's widgets...
}
}
}
You can expand on the above idea to use a Loader so that the Dialog
gets created lazily.
Girish
More information about the Qt-qml
mailing list