oboy/qt/main.qml
2016-04-18 23:06:17 +02:00

57 lines
1.3 KiB
QML

import QtQuick 2.5
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
ApplicationWindow {
id: root
visible: true
width: 256
height: 128
title: qsTr("OBoy")
menuBar: MenuBar {
Menu {
title: qsTr("File")
MenuItem {
text: qsTr("&Open")
onTriggered: console.log("Open action triggered");
}
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
}
}
Menu {
title: qsTr("View")
MenuItem {
text: qsTr("Background maps")
onTriggered: {
console.log("Background maps");
var component = Qt.createComponent("BackgroundMap.qml")
var bgMap = component.createObject(root)
bgMap.show()
}
}
}
}
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();
}
}
}