-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
65 lines (59 loc) · 2.11 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.0
// Ez lesz az alkalmazás főablaka
ApplicationWindow {
title: qsTr("Drawing car")
width: 640
height: 480
visible: true
// Signalok, melyeket a C++ oldalon fogunk C++ slotokhoz kötni
// az DCApplication osztály konstruktorában.
signal resetCommandCpp()
signal accelerateCommandCpp()
signal stopCommandCpp()
signal selfTestCommandCpp()
signal carHeightCommandCpp(int height);
// Az ablak menuBar tulajdonságának értékül adunk egy MenuBar példányt, amit itt rakunk össze.
menuBar: MenuBar {
// A MenuBar-on belül vannak a menük, Menu példányok formájában. Most csak egy "Exit" menünk van,
// benne egyetlen menüponttal.
Menu {
// A menünek a title tulajdonsága egyúttal az & jellel megadja a billentyű parancsot is: Alt-x
title: qsTr("&Exit")
// Az egyetlen menüpont
MenuItem {
text: qsTr("E&xit")
// A menüpont Triggered signaljához kapcsolunk eseménykezelőt
// úgy, hogy értéket adunk az onTriggered tulajdonságnak. Az eseménykezelőt
// JavaScript nyelven írjuk meg.
onTriggered: Qt.quit();
}
}
}
/* Instantiating the MainForm control which contains everything in the main form,
except the menu. */
// A MainForm elem példányosítása. Itt adjuk meg az ID-ját, a helyét (anchors),
// valamint a signaljainak az eseménykezelőit.
MainForm {
id: mainFormControl
anchors.fill: parent
// Az eseménykezelőkben tovább hívjuk az itteni signalokat a C++ oldal felé.
onResetCommand: {
resetCommandCpp();
}
onAccelerateCommand: {
accelerateCommandCpp();
}
onStopCommand: {
stopCommandCpp();
}
onSelfTestCommand: {
selfTestCommandCpp();
}
onCarHeightCommand: {
carHeightCommandCpp(height);
}
}
}