Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
qt_view.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "aria/abi/export.hpp"
5
6#include <QObject>
7#include <QPointer>
8#include <QWidget>
9
10namespace aria::adapters::qt6 {
11
25class ARIA_QT6_API QtView final : public binding::IView {
26public:
27 explicit QtView(QObject* w) noexcept : w_(w) {
28 if (w) {
29 // No context object: the connection is owned by the sender.
30 // We disconnect explicitly in the destructor so a QtView that
31 // dies before its widget cannot be called back.
32 destroyed_conn_ = QObject::connect(
33 w, &QObject::destroyed,
34 [this]() noexcept { fire_destroy_(); });
35 }
36 }
37
38 ~QtView() override {
39 QObject::disconnect(destroyed_conn_);
40 // ~IView fires the destroy signal as a last resort; it is
41 // idempotent, so a widget-first teardown does not double-fire.
42 }
43
44 [[nodiscard]] std::string_view kind() const noexcept override { return "qt6"; }
45
46 [[nodiscard]] QObject* object() const noexcept { return w_.data(); }
47
48 template<typename T>
49 [[nodiscard]] T* as() const noexcept { return qobject_cast<T*>(w_.data()); }
50
51private:
52 QPointer<QObject> w_;
53 QMetaObject::Connection destroyed_conn_;
54};
55
56} // namespace aria::adapters::qt6
~QtView() override
Definition qt_view.hpp:38
QtView(QObject *w) noexcept
Definition qt_view.hpp:27
std::string_view kind() const noexcept override
Definition qt_view.hpp:44
QObject * object() const noexcept
Definition qt_view.hpp:46
T * as() const noexcept
Definition qt_view.hpp:49
Abstract platform widget reference.
Definition view_adapter.hpp:28
void fire_destroy_() noexcept
Invoked by ~IView() to fan out the notification — this is the last-resort trigger.
#define ARIA_QT6_API
Definition export.hpp:57
Definition qt_adapter.hpp:12