File tree Expand file tree Collapse file tree 10 files changed +114
-3
lines changed Expand file tree Collapse file tree 10 files changed +114
-3
lines changed Original file line number Diff line number Diff line change
1
+ load ("//bazel/rules:qt.bzl" , "qt_cc_binary" , "qt_resource" )
2
+
3
+ qt_resource (
4
+ name = "qrc" ,
5
+ files = [
6
+ "main.qml" ,
7
+ ],
8
+ )
9
+
10
+ qt_cc_binary (
11
+ name = "bin" ,
12
+ srcs = ["main.cpp" ],
13
+ deps = [
14
+ ":qrc" ,
15
+ ],
16
+ )
Original file line number Diff line number Diff line change
1
+ # How to Run
2
+
3
+ Run the following command to compile for x86:
4
+
5
+ ```bash
6
+ bazel run //examples/qt/qml:bin
7
+ ```
8
+
9
+ Run the following command to compile for aarch64:
10
+
11
+ ```bash
12
+ bazel build //examples/qt/qml:bin --platforms=//bazel/platforms:aarch64_linux
13
+ ```
Original file line number Diff line number Diff line change
1
+ #include < QtCore/QString>
2
+ #include < QtQml/QQmlApplicationEngine>
3
+ #include < QtQml/QQmlContext>
4
+ #include < QtWidgets/QApplication>
5
+
6
+ auto main (int argc, char *argv[]) -> int {
7
+ QGuiApplication app (argc, argv);
8
+
9
+ QQmlApplicationEngine engine;
10
+
11
+ QString button_text = " Click me!" ;
12
+ engine.rootContext ()->setContextProperty (" buttonText" , button_text);
13
+
14
+ engine.load (QUrl (QStringLiteral (" qrc:/examples/qt/qml/main.qml" )));
15
+
16
+ return QGuiApplication::exec ();
17
+ }
Original file line number Diff line number Diff line change
1
+ import QtQuick 6.0
2
+ import QtQuick.Controls 6.0
3
+
4
+ ApplicationWindow {
5
+ visible: true
6
+ width: 640
7
+ height: 480
8
+ title: " Qt6 QML Example"
9
+
10
+ // Define properties
11
+ property color bgColor: " lightblue"
12
+ property int fontSize: 24
13
+
14
+ Rectangle {
15
+ width: parent .width
16
+ height: parent .height
17
+ color: bgColor
18
+
19
+ // Text element that changes based on interaction
20
+ Text {
21
+ id: label
22
+ text: " Adjust me!"
23
+ anchors .centerIn : parent
24
+ font .pixelSize : fontSize
25
+ color: " black"
26
+ }
27
+
28
+ // Slider to adjust font size
29
+ Slider {
30
+ id: fontSizeSlider
31
+ from: 10
32
+ to: 100
33
+ value: fontSize
34
+ anchors .top : label .bottom
35
+ anchors .horizontalCenter : parent .horizontalCenter
36
+ width: parent .width * 0.8
37
+ onValueChanged: {
38
+ fontSize = fontSizeSlider .value
39
+ }
40
+ }
41
+
42
+ // CheckBox to toggle background color
43
+ CheckBox {
44
+ text: " Change Background Color"
45
+ anchors .top : fontSizeSlider .bottom
46
+ anchors .horizontalCenter : parent .horizontalCenter
47
+ onCheckedChanged: {
48
+ bgColor = checked ? " lightgreen" : " lightblue"
49
+ }
50
+ }
51
+
52
+ // Button to reset the font size and background color
53
+ Button {
54
+ text: " Reset"
55
+ anchors .top : checkBox .bottom
56
+ anchors .horizontalCenter : parent .horizontalCenter
57
+ onClicked: {
58
+ fontSize = 24
59
+ bgColor = " lightblue"
60
+ fontSizeSlider .value = 24
61
+ checkBox .checked = false
62
+ }
63
+ }
64
+ }
65
+ }
File renamed without changes.
Original file line number Diff line number Diff line change 3
3
Run the following command to compile for x86:
4
4
5
5
```bash
6
- bazel run //examples/qt:bin
6
+ bazel run //examples/qt/ui :bin
7
7
```
8
8
9
9
Run the following command to compile for aarch64:
10
10
11
11
```bash
12
- bazel build //examples/qt:bin --platforms=//bazel/platforms:aarch64_linux
12
+ bazel build //examples/qt/ui :bin --platforms=//bazel/platforms:aarch64_linux
13
13
```
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 6
6
#include < QtWidgets/QMainWindow>
7
7
#include < QtWidgets/QPushButton>
8
8
9
- #include " examples/qt/ui_mainwindow.h"
9
+ #include " examples/qt/ui/ ui_mainwindow.h"
10
10
11
11
class MainWindow : public QMainWindow {
12
12
Q_OBJECT
File renamed without changes.
You can’t perform that action at this time.
0 commit comments