Skip to content

Commit e5d7f45

Browse files
committed
bazel: add support for qt
Add qt hello world
1 parent c1efd83 commit e5d7f45

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

WORKSPACE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,25 @@ http_archive(
6464
"https://github.com/bazelbuild/buildtools/archive/refs/tags/4.2.2.tar.gz",
6565
],
6666
)
67+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
68+
69+
git_repository(
70+
name = "com_justbuchanan_rules_qt",
71+
remote = "https://github.com/justbuchanan/bazel_rules_qt.git",
72+
branch = "master",
73+
)
74+
75+
load("@com_justbuchanan_rules_qt//:qt_configure.bzl", "qt_configure")
76+
77+
qt_configure()
78+
79+
load("@local_config_qt//:local_qt.bzl", "local_qt_path")
80+
81+
new_local_repository(
82+
name = "qt",
83+
build_file = "@com_justbuchanan_rules_qt//:qt.BUILD",
84+
path = local_qt_path(),
85+
)
86+
87+
load("@com_justbuchanan_rules_qt//tools:qt_toolchain.bzl", "register_qt_toolchains")
88+
register_qt_toolchains()

examples/qt/BUILD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
load("@com_justbuchanan_rules_qt//:qt.bzl", "qt_cc_library", "qt_ui_library")
2+
3+
cc_binary(
4+
name = "main",
5+
srcs = ["main.cpp"],
6+
copts = ["-fpic"],
7+
deps = [
8+
"@qt//:qt_widgets",
9+
],
10+
)

examples/qt/README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How to Run:
2+
3+
```bash
4+
bazel run //examples/qt:main
5+
```

examples/qt/main.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include <QtWidgets/QApplication>
2+
#include <QtWidgets/QPushButton>
3+
4+
auto main(int argc, char *argv[]) -> int {
5+
QApplication app(argc, argv); // Create the QApplication object
6+
7+
// Create a simple push button with the text "Hello World"
8+
QPushButton button("Hello World");
9+
10+
// Show the button
11+
button.show();
12+
13+
// Start the application's event loop
14+
return app.exec();
15+
}

0 commit comments

Comments
 (0)