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?


  • Moderators

    Calling C++ for help is probably the only option.



  • (and yeah, I know this is stone age ui style, that's not the point....)



  • 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++?


  • Moderators

    You can use Window QML element, AFAIK. I'm not too fluent in Quick Controls, so I can't say for sure, though.



  • 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...


  • Moderators

    That could very well be. Please post the solution if you may, it might be useful to others, myself included :D


  • Moderators

    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.0

    ApplicationWindow {
    title: qsTr("Hello World")
    id: mainWindow
    width: 640
    height: 480

    menuBar: 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!"
            }
        }
    }
    

    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.