Qt Quick Controls Dialog?
-
Ok, complete noob here who was tempted by the 5.2 beta announcement to check out QML for the first time.
I installed the beta, fired up QtCreator 3, and started a new "Qt Quick 2 UI with controls" project to play around. I started to recreate the UI of my last GUI project, and immediatly hit the wall.
How do I do the good old "Help > About ..." dialog?
I found the ColorDialog and FileDialog, but no mention of a generic dialog in the docs. Googling yieds some references to an experimental dialog component in 5.1 and some ways to do dialogs using Qt Quick 1.0 without controls, which is probably not what I want.
What would the proper way of doing this with 5.2 be?
-
Calling C++ for help is probably the only option.
-
You can use Window QML element, AFAIK. I'm not too fluent in Quick Controls, so I can't say for sure, though.
-
That could very well be. Please post the solution if you may, it might be useful to others, myself included :D
-
Hi,
I haven't used it myself, but have a look at "QtQuick.Window":http://qt-project.org/doc/qt-5.1/qtquick/qml-qtquick-window2-window.html I'd imagine you can create a modal window to act as an About box.
EDIT: That was exactly what Sierdzio recommended earlier. I need to read better :P
-
@import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0ApplicationWindow {
title: qsTr("Hello World")
id: mainWindow
width: 640
height: 480menuBar: MenuBar { Menu { title: qsTr("File") MenuItem { text: qsTr("Exit") onTriggered: Qt.quit(); } } Menu { title: qsTr("Help") MenuItem { text: qsTr("About...") onTriggered: aboutWin.show(); } } } Button { text: qsTr("Hello World") anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter } Window { id: aboutWin; color: "black"; title: "About Me"; x: mainWindow.x + mainWindow.width/2 - width/2 y: mainWindow.y + mainWindow.height/2 - height/2 Rectangle { anchors.fill: parent anchors.margins: 10 Text { anchors.centerIn: parent text: "Glory Be!" } } }
}
@