-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.mbt
More file actions
39 lines (31 loc) · 705 Bytes
/
main.mbt
File metadata and controls
39 lines (31 loc) · 705 Bytes
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
///|
using @qt {
type NullptrError,
type QObject,
type QApplication,
type QWidget,
type QBoxLayout,
type QPushButton,
type QLabel,
}
///|
fn main raise NullptrError {
let app = QApplication::new(@env.args())
let mut count = 0
let label = QLabel::new()
label.setText("Count: 0")
let button = QPushButton::new()
button.setText("Click me!")
let _ = QObject::connect(button.clicked(), _ => {
count += 1
label.setText("Count: \{count}")
})
let layout = QBoxLayout::horizontal()
layout.addWidget(button)
layout.addWidget(label)
let window = QWidget::new()
window.setWindowTitle("Counter")
window.setLayout(layout)
window.show()
let _ = app.exec()
}