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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
//! # qtrs — Rust-style Qt6 bindings
//!
//! A type-safe, builder-pattern-driven Qt6 GUI library for Rust.
//! Built on [`cxx`] for C++ interop, with RAII memory management,
//! signal/callback bridging, and a fluent builder API.
//!
//! ## Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! qtrs = "0.5.1"
//! ```
//!
//! ## Design principles
//!
//! - Builder pattern everywhere — chain `.title("X").size(800, 600).show()`
//! - RAII cleanup — widgets are automatically deleted on `Drop`, with
//! parent-child awareness (widgets with a Qt parent skip C++ deletion to
//! avoid double-free).
//! - Type-safe layout ownership — adding a widget to a layout transfers
//! ownership; the layout drops its children when it goes out of scope.
//! - Zero-cost signal bridging — Qt signals invoke Rust closures via a
//! single global trampoline; context tokens are plain `u64` values.
//!
//! ## Architecture
//!
//! | Layer | Crate module | What it does |
//! |---|---|---|
//! | C++ glue | *(internal)* | Inline wrappers around Qt5/Qt6 API |
//! | cxx bridge | [`ffi`] | Opaque C++ types + `extern "C++"` signatures |
//! | Safe wrappers | [`app`], [`widget`], [`button`], ... | Builder patterns, RAII, signals |
//! | Public API | *(this module)* | Re-exports of all safe types |
//!
//! ## Widget gallery
//!
//! ### Windows & Containers
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`Application`] | `QApplication` | — |
//! | [`Widget`] | `QWidget` | — |
//! | [`MainWindow`] | `QMainWindow` | — |
//! | [`GroupBox`] | `QGroupBox` | — |
//! | [`TabWidget`] | `QTabWidget` | `on_current_changed(i32)` |
//! | [`StackedWidget`] | `QStackedWidget` | `on_current_changed(i32)` |
//! | [`ScrollArea`] | `QScrollArea` | — |
//! | [`Splitter`] | `QSplitter` | — |
//!
//! ### Buttons & Controls
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`PushButton`] | `QPushButton` | `on_clicked` |
//! | [`ToolButton`] | `QToolButton` | `on_clicked`<br>`on_toggled(bool)` |
//! | [`CheckBox`] | `QCheckBox` | `on_toggled(bool)` |
//! | [`RadioButton`] | `QRadioButton` | `on_toggled(bool)` |
//! | [`Slider`] | `QSlider` | `on_value_changed(i32)` |
//! | [`SpinBox`] | `QSpinBox` | `on_value_changed(i32)` |
//! | [`ComboBox`] | `QComboBox` | `on_current_text_changed`<br>`on_current_index_changed(i32)` |
//!
//! ### Text & Display
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`Label`] | `QLabel` | — |
//! | [`LineEdit`] | `QLineEdit` | `on_return_pressed` |
//! | [`TextEdit`] | `QTextEdit` | `on_text_changed` |
//! | [`PlainTextEdit`] | `QPlainTextEdit` | `on_text_changed`<br>`on_cursor_position_changed` |
//! | [`TextBrowser`] | `QTextBrowser` | `on_anchor_clicked(String)`<br>`on_text_changed` |
//! | [`ProgressBar`] | `QProgressBar` | — |
//!
//! ### Item Views
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`ListWidget`] | `QListWidget` | `on_item_clicked(String)`<br>`on_item_double_clicked(String)`<br>`on_current_item_changed(String)` |
//! | [`TableWidget`] | `QTableWidget` | `on_cell_clicked`<br>`on_cell_double_clicked`<br>`on_current_cell_changed` |
//! | [`TreeWidget`] | `QTreeWidget` | `on_item_clicked(String)`<br>`on_item_double_clicked(String)`<br>`on_item_expanded(String)`<br>`on_item_collapsed(String)`<br>`on_current_item_changed(String)` |
//!
//! ### Date & Time
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`DateEdit`] | `QDateEdit` | `on_date_changed(String)` |
//! | [`TimeEdit`] | `QTimeEdit` | `on_time_changed(String)` |
//! | [`DateTimeEdit`] | `QDateTimeEdit` | `on_date_time_changed(String)` |
//! | [`CalendarWidget`] | `QCalendarWidget` | `on_selection_changed`<br>`on_activated(String)` |
//!
//! ### Menus & Toolbars
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`Action`] | `QAction` | `on_triggered(bool)`<br>`on_toggled(bool)` |
//! | [`Menu`] | `QMenu` | — |
//! | [`MenuBar`] | `QMenuBar` | — |
//! | [`ToolBar`] | `QToolBar` | per-action callbacks via `add_action` |
//! | [`StatusBar`] | `QStatusBar` | — |
//!
//! ### Dialogs
//!
//! | Type | Qt class | Notes |
//! |---|---|---|
//! | [`MessageBox`] | `QMessageBox` | Builder + `exec()`, static `about()` |
//! | [`FileDialog`] | `QFileDialog` | `open_file`, `save_file`, `select_directory` (static) |
//! | [`ProgressDialog`] | `QProgressDialog` | Builder with `set_value` / `was_canceled` |
//! | `inputdialog` | `QInputDialog` | `get_text`, `get_int`, `get_double`, `get_item` (static) |
//! | `dialog` | `QMessageBox` | `information`, `warning`, `critical`, `question` (static) |
//!
//! ### Layouts
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`VBoxLayout`] | `QVBoxLayout` | — |
//! | [`HBoxLayout`] | `QHBoxLayout` | — |
//! | [`GridLayout`] | `QGridLayout` | — |
//!
//! ### Styling & Utilities
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`Frame`] | `QFrame` | — (shape/shadow decorations) |
//! | [`Font`] | `QFont` | — (builder: family, size, weight) |
//! | [`FontExt`] | *(trait)* | `font()` / `set_font()` on all widgets |
//! | [`Shortcut`] | `QShortcut` | `on_activated()` (QObject) |
//!
//! ### System
//!
//! | Type | Qt class | Signals |
//! |---|---|---|
//! | [`Timer`] | `QTimer` | `on_timeout`<br>`single_shot(ms, fn)` |
//! | [`SystemTrayIcon`] | `QSystemTrayIcon` | `on_activated(TrayIconReason)` |
//! | [`UiLoader`] | `QUiLoader` | `.ui` file loading |
//! | [`Point`] | `QPoint` | — |
//!
//! ## Quick example
//!
//! ```no_run
//! use qtrs::prelude::*;
//!
//! fn main() {
//! let app = Application::new();
//!
//! let mut window = Widget::new()
//! .title("Hello, qtrs!")
//! .size(400, 300)
//! .build();
//!
//! let mut layout = VBoxLayout::with_parent(&window);
//!
//! let btn = PushButton::new("Click me")
//! .on_clicked(|| println!("clicked!"))
//! .build();
//! let label = Label::new("Welcome!").build();
//!
//! layout.add(btn);
//! layout.add(label);
//!
//! window.set_layout(&layout);
//! window.show();
//!
//! app.exec();
//! }
//! ```
//!
//! ## Thread safety
//!
//! Qt GUI classes are **not thread-safe**. All widget creation, mutation,
//! and the event loop must happen on the main thread. This library does
//! not add any synchronisation — you are responsible for staying on the
//! right thread, just as in C++ Qt.
//!
//! ## Linking
//!
//! Qt6 (Core, Gui, Widgets) must be installed with development headers.
//! The build script uses `qmake` to locate them. If you see
//! `Qt not found!`, install the `qt6-base-dev` package
//! (or equivalent) for your distribution.
// ================================================
// Re-Exports
// ================================================
pub use Action;
pub use Application;
pub use PushButton;
pub use CheckBox;
pub use ComboBox;
pub use GridLayout;
pub use LineEdit;
pub use ;
pub use Label;
pub use ;
pub use ListWidget;
pub use Slider;
pub use TextEdit;
pub use Timer;
pub use ;
pub use ProgressBar;
pub use RadioButton;
pub use GroupBox;
pub use TabWidget;
pub use SpinBox;
pub use ProgressDialog;
pub use ScrollArea;
pub use Splitter;
pub use StackedWidget;
pub use StatusBar;
pub use TableWidget;
pub use ToolBar;
pub use TreeWidget;
pub use MainWindow;
pub use ;
pub use ;
pub use ;
pub use DateEdit;
pub use DateTimeEdit;
pub use FileDialog;
pub use PlainTextEdit;
pub use Point;
pub use TextBrowser;
pub use TimeEdit;
pub use ;
pub use UiLoader;
pub use Frame;
pub use ToolButton;
pub use CalendarWidget;
pub use Shortcut;
pub use SystemTrayIcon;
pub use StandardItemModel;
pub use TableView;
pub use ListView;
pub use TreeView;
pub use ItemSelectionModel;
// ============================================================
// Prelude
// ============================================================
/// Prelude: commonly used types and traits.