main.qml.tpl 1.12 KB
Newer Older
1 2
import QtQuick %{QtQuickVersion}
import QtQuick.Controls %{QtQuickControlsVersion}
3
@if %{IsUiFileInUse}
4 5
import QtQuick.Dialogs %{QtQuickDialogsVersion}
@endif
6 7

ApplicationWindow {
8
    visible: true
9 10
    width: 640
    height: 480
11
    title: qsTr("Hello World")
12 13 14

    menuBar: MenuBar {
        Menu {
15
            title: qsTr("File")
16 17
            MenuItem {
                text: qsTr("&Open")
18
                onTriggered: console.log("Open action triggered");
19 20
            }
            MenuItem {
21
                text: qsTr("Exit")
22 23 24 25 26
                onTriggered: Qt.quit();
            }
        }
    }

27
@if %{IsUiFileInUse}
28 29 30 31 32 33 34 35 36 37 38 39 40 41
    MainForm {
        anchors.fill: parent
        button1.onClicked: messageDialog.show(qsTr("Button 1 pressed"))
        button2.onClicked: messageDialog.show(qsTr("Button 2 pressed"))
    }

    MessageDialog {
        id: messageDialog
        title: qsTr("May I have your attention, please?")

        function show(caption) {
            messageDialog.text = caption;
            messageDialog.open();
        }
42
    }
43 44 45 46 47 48
@else
    Label {
        text: qsTr("Hello World")
        anchors.centerIn: parent
    }
@endif
49
}