Qt Quick Controls Dialog?
-
wrote on 24 Oct 2013, 17:37 last edited by
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.
-
wrote on 24 Oct 2013, 17:43 last edited by
(and yeah, I know this is stone age ui style, that's not the point....)
-
wrote on 25 Oct 2013, 07:08 last edited by
So I am to understand that as things stand in 5.2, QT Quick Controls are only useable in my main application window, and any dialogs or popups should be implemented in C++?
-
You can use Window QML element, AFAIK. I'm not too fluent in Quick Controls, so I can't say for sure, though.
-
wrote on 25 Oct 2013, 07:35 last edited by
OK, got it after a bit more digging. It wasn't hard at all, it's just that there is no docs for QtQCntrl 5.2 yet and a lot of the stuff on Stackoverflow and Youtube is very outdated...
-
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
-
wrote on 25 Oct 2013, 08:05 last edited by
@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!" } } }
}
@
9/9