KDDockWidgets API Documentation 2.0
Loading...
Searching...
No Matches
qtquick/views/View.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5 Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6
7 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8
9 Contact KDAB at <info@kdab.com> for commercial licensing options.
10*/
11
12#include "View.h"
13#include "core/Utils_p.h"
14#include "core/View_p.h"
15#include "ViewWrapper_p.h"
16#include "core/layouting/Item_p.h"
17#include "core/ScopedValueRollback_p.h"
18#include "qtquick/Window_p.h"
19#include "qtquick/Platform.h"
20#include "core/Group.h"
21
22#include <QtQuick/private/qquickitem_p.h>
23#include <qpa/qplatformwindow.h>
24#include <QtGui/private/qhighdpiscaling_p.h>
25#include <QGuiApplication>
26#include <QFile>
27#include <QQmlContext>
28
29using namespace KDDockWidgets;
30using namespace KDDockWidgets::QtQuick;
31
32namespace KDDockWidgets::QtQuick {
33
39class MouseEventRedirector : public QObject
40{
42public:
43 explicit MouseEventRedirector(QQuickItem *eventSource, View *eventTarget)
44 : QObject(eventTarget)
45 , m_eventSource(eventSource)
46 , m_eventTarget(eventTarget)
47 {
48 eventSource->installEventFilter(this);
49
50 // Each source can only have one MouseEventRedirector
51 auto oldRedirector = s_mouseEventRedirectors.take(eventSource);
52 if (oldRedirector) {
53 eventSource->removeEventFilter(oldRedirector);
54 oldRedirector->deleteLater();
55 }
56
57 s_mouseEventRedirectors.insert(eventSource, this);
58 }
59
60 static MouseEventRedirector *redirectorForSource(QObject *eventSource)
61 {
62 return s_mouseEventRedirectors.value(eventSource);
63 }
65 ~MouseEventRedirector() override;
66
67 bool eventFilter(QObject *source, QEvent *ev) override
68 {
69 if (QHoverEvent *hev = hoverEvent(ev)) {
71 m_eventTarget->onHoverEvent(
72 hev, m_eventSource->mapToGlobal(Qt5Qt6Compat::eventPos(hev)).toPoint());
73 return false;
74 }
76 QMouseEvent *me = mouseEvent(ev);
77 if (!me)
78 return false;
80 // MouseArea.enable is different from Item.enabled. The former still lets the events
81 // go through event loops. So query MouseArea.enable here and bail out if false.
82 const QVariant v = source->property("enabled");
83 if (v.isValid() && !v.toBool())
84 return false;
86 // Finally send the event
87 m_eventTarget->setProperty("cursorPosition", m_eventSource->property("cursorPosition"));
88 QPointer<QObject> lifeGuard(this);
89 qGuiApp->sendEvent(m_eventTarget, me);
91 if (!lifeGuard) {
92 // m_eventTarget was deleted, and so was "this"
93 return true;
94 }
96 m_eventTarget->setProperty("cursorPosition", CursorPosition_Undefined);
98 return false;
99 }
101 QQuickItem *const m_eventSource;
102 View *const m_eventTarget;
103 static QHash<QObject *, MouseEventRedirector *> s_mouseEventRedirectors;
106QHash<QObject *, MouseEventRedirector *> MouseEventRedirector::s_mouseEventRedirectors = {};
108MouseEventRedirector::~MouseEventRedirector()
110 s_mouseEventRedirectors.remove(m_eventSource);
113}
117 return flags & (Qt::Window | Qt::Tool);
120static QQuickItem *actualParentItem(QQuickItem *candidateParentItem, Qt::WindowFlags flags)
122 // When we have a top-level, such as FloatingWindow, we only want to set QObject parentship
123 // and not parentItem.
124 return flagsAreTopLevelFlags(flags) ? nullptr : candidateParentItem;
125}
127View::View(Core::Controller *controller, Core::ViewType type, QQuickItem *parent,
129 : QQuickItem(actualParentItem(parent, flags))
130 , View_qt(controller, type, this)
131 , m_windowFlags(flags)
132{
133 if (parent && flagsAreTopLevelFlags(flags)) {
134 // See comment in actualParentItem(). We set only the QObject parent. Mimics QWidget
135 // behaviour
139 connect(this, &QQuickItem::widthChanged, this, [this] {
140 if (!Core::View::d->aboutToBeDestroyed() && !m_inDtor) { // If Window is being destroyed we don't bother
141 onResize(Core::View::size());
142 updateGeometry();
144 });
146 connect(this, &QQuickItem::heightChanged, this, [this] {
147 if (!Core::View::d->aboutToBeDestroyed() && !m_inDtor) { // If Window is being destroyed we don't bother
148 onResize(Core::View::size());
149 updateGeometry();
151 });
153 _setSize({ 800, 800 });
154}
155
157{
158 setSize(rect.width(), rect.height());
160}
161
162QQuickItem *View::createItem(QQmlEngine *engine, const QString &filename, QQmlContext *context)
164 QQmlComponent component(engine, filename);
165 QObject *obj = component.create(context);
166 if (!obj) {
167 qWarning() << Q_FUNC_INFO << component.errorString();
168 return nullptr;
169 }
170
171 return qobject_cast<QQuickItem *>(obj);
172}
173
174void View::redirectMouseEvents(QQuickItem *source)
176 if (auto existingRedirector = MouseEventRedirector::redirectorForSource(source)) {
177 if (existingRedirector->m_eventTarget == this) {
178 // Nothing to do. The specified event source is already redirecting to this instance
179 return;
180 }
181 }
182
183 new MouseEventRedirector(source, this);
184}
185
186void View::sendVisibleChangeEvent()
187{
188 if (Core::View::d->freed())
189 return;
190
191 if (m_inSetParent) {
192 // Setting parent to nullptr will emit visible true in QtQuick
193 // which we don't want, as we're going to hide it (as we do with QtWidgets)
194 return;
195 }
196
197 QEvent ev(isVisible() ? QEvent::Show : QEvent::Hide);
198 event(&ev);
199}
200
201void View::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
202{
203 if (m_inDtor)
204 return;
205
206 QQuickItem::itemChange(change, data);
207
208 // Emulate the QWidget behaviour as QQuickItem doesn't receive some QEvents.
209 if (change == QQuickItem::ItemVisibleHasChanged)
210 sendVisibleChangeEvent();
211}
212
213void View::updateNormalGeometry()
214{
215 QWindow *window = QQuickItem::window();
216 if (!window) {
217 return;
218 }
219
221 if (const QPlatformWindow *pw = window->handle()) {
222 normalGeometry = QHighDpi::fromNativePixels(pw->normalGeometry(), pw->window());
223 }
224
225 if (!normalGeometry.isValid() && isNormalWindowState(WindowState(window->windowState()))) {
226 normalGeometry = window->geometry();
227 }
228
229 if (normalGeometry.isValid()) {
231 }
232}
233
234void View::move(int x, int y)
235{
236 if (isRootView()) {
237 if (QWindow *w = QQuickItem::window()) {
238 w->setPosition(x, y);
239 return;
240 }
241 }
242
243 QQuickItem::setX(x);
244 QQuickItem::setY(y);
246}
247
249{
250 if (ev->type() == QEvent::Close)
251 Core::View::d->requestClose(static_cast<QCloseEvent *>(ev));
252
253 return QQuickItem::event(ev);
254}
255
257{
258 if (qobject_cast<QWindow *>(watched)) {
259 if (m_mouseTrackingEnabled) {
260 switch (ev->type()) {
264 ev->ignore();
265 qGuiApp->sendEvent(this, ev);
266 // qDebug() << "Mouse event" << ev;
267 if (ev->isAccepted())
268 return true;
269 break;
270 default:
271 break;
272 }
273 }
274
275 if (ev->type() == QEvent::Resize || ev->type() == QEvent::Move) {
276 updateNormalGeometry();
277 } else if (ev->type() == QEvent::WindowStateChange) {
279 }
280 }
281
282 return QQuickItem::eventFilter(watched, ev);
283}
284
285bool View::close(QQuickItem *item)
286{
287 if (auto viewqtquick = qobject_cast<View *>(item)) {
288 QCloseEvent ev;
289 viewqtquick->Core::View::d->closeRequested.emit(&ev);
290
291 if (ev.isAccepted()) {
292 viewqtquick->setVisible(false);
293 return true;
294 }
295 }
296
297 return false;
298}
299
301{
302 return close(this);
303}
304
305void View::QQUICKITEMgeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
306{
307 // Send a few events manually, since QQuickItem doesn't do it for us.
308 QQuickItem::QQUICKITEMgeometryChanged(newGeometry, oldGeometry);
309
310 // Not calling event() directly, otherwise it would skip event filters
311
312 if (newGeometry.size() != oldGeometry.size()) {
314 qGuiApp->sendEvent(this, &ev);
315 }
316
317 if (newGeometry.topLeft() != oldGeometry.topLeft()) {
319 qGuiApp->sendEvent(this, &ev);
320 }
321
322 Q_EMIT itemGeometryChanged();
323}
324
325bool View::isVisible() const
326{
327 if (QWindow *w = QQuickItem::window()) {
328 if (!w->isVisible())
329 return false;
330 }
331
332 // QQuickItemPrivate::explicitVisible is the actual visible state independently from the parent
333 // being visible or not. This is what we want to save with LayoutSaver.
334 // For now, we have no use case to know what is the effectiveVisible state. If we need it, then we'll
335 // need to have more API for this.
336
337 auto priv = QQuickItemPrivate::get(this);
338 return priv->explicitVisible;
339}
340
341void View::setVisible(bool is)
342{
343 if (isRootView()) {
344 if (QWindow *w = QQuickItem::window()) {
345 if (is && !w->isVisible()) {
346 w->show();
347 } else if (!is && w->isVisible()) {
348 w->hide();
349 }
350 }
351 }
352
353 QQuickItem::setVisible(is);
354
355#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
356 // Workaround QTBUG-112838, QQuickItem::itemChanged() isn't called anymore if there's no parent
357 if (is && !parentItem() && !QQuickItem::isVisible()) {
358 sendVisibleChangeEvent();
359 }
360#endif
361}
362
364{
365 auto priv = QQuickItemPrivate::get(this);
366 return !priv->explicitVisible;
367}
368
369void View::setSize(int w, int h)
370{
371 const auto newSize = QSize(w, h).expandedTo(minSize());
372 _setSize(newSize);
373}
374
375void View::_setSize(QSize newSize)
376{
377 // Like setSize() but does not honour minSize()
378
379 if (isRootView()) {
380 if (QWindow *window = QQuickItem::window()) {
381
382 if (window->size() != newSize) {
383 QRect windowGeo = window->geometry();
384 windowGeo.setSize(newSize);
385 window->setGeometry(windowGeo);
386 }
387 }
388 }
389
390 QQuickItem::setSize(newSize);
391}
392
393std::shared_ptr<Core::View> View::rootView() const
394{
395 if (Core::Window::Ptr window = View::window())
396 return window->rootView();
397
398 auto thisNonConst = const_cast<View *>(this);
399 return thisNonConst->asWrapper();
400}
401
402void View::makeItemFillParent(QQuickItem *item)
403{
404 if (!item) {
405 qWarning() << Q_FUNC_INFO << "Invalid item";
406 return;
407 }
408
409 QQuickItem *parentItem = item->parentItem();
410 if (!parentItem) {
411 qWarning() << Q_FUNC_INFO << "Invalid parentItem for" << item;
412 return;
413 }
414
415 QObject *anchors = item->property("anchors").value<QObject *>();
416 if (!anchors) {
417 qWarning() << Q_FUNC_INFO << "Invalid anchors for" << item;
418 return;
419 }
420
421 anchors->setProperty("fill", QVariant::fromValue(parentItem));
422}
423
425{
426 if (enable)
427 m_widgetAttributes |= attr;
428 else
429 m_widgetAttributes &= ~attr;
430}
431
433{
434 return m_widgetAttributes & attr;
435}
436
438{
439 if (on) {
440 m_windowFlags |= f;
441 } else {
442 m_windowFlags &= ~f;
443 }
444}
445
447{
448 return m_windowFlags;
449}
450
452{
453 const QSize min = property("kddockwidgets_min_size").toSize();
454 return min.expandedTo(Core::Item::hardcodedMinimumSize);
455}
456
458{
459 const QSize max = property("kddockwidgets_max_size").toSize();
460 return max.isEmpty() ? Core::Item::hardcodedMaximumSize
461 : max.boundedTo(Core::Item::hardcodedMaximumSize);
462}
463
465{
466 if (isRootView()) {
467 if (QWindow *w = QQuickItem::window()) {
468 return w->geometry();
469 }
470 }
471
472 return QRect(QPointF(QQuickItem::x(), QQuickItem::y()).toPoint(), QQuickItem::size().toSize());
473}
474
476{
477 return m_normalGeometry;
478}
479
481{
482 m_normalGeometry = geo;
483}
484
486{
487 if (maxSizeHint() != sz) {
488 setProperty("kddockwidgets_max_size", sz);
490 Core::View::d->layoutInvalidated.emit();
491 }
492}
493
494void View::setWidth(int w)
495{
496 QQuickItem::setWidth(w);
497}
498
500{
501 QQuickItem::setHeight(h);
502}
503
505{
506 setWidth(w);
507 setMinimumSize({ w, minSize().height() });
509}
510
512{
513 setHeight(h);
514 setMinimumSize({ minSize().width(), h });
515 setMaximumSize({ maxSizeHint().width(), h });
516}
517
519{
520 setFixedWidth(sz.width());
521 setFixedHeight(sz.height());
522}
523
525{
526 setVisible(true);
527}
528
530{
531 setVisible(false);
532}
533
535{
536 Q_EMIT geometryUpdated();
537}
538
540{
541 // Nothing to do for QtQuick
542}
543
544void View::setParent(QQuickItem *parentItem)
545{
546 {
547 ScopedValueRollback guard(m_inSetParent, true);
548 QQuickItem::setParent(parentItem);
549 QQuickItem::setParentItem(parentItem);
550 }
551
552 // Mimic QWidget::setParent(), hide widget when setting parent
553 // Only if no parent item though, as that causes binding loops. Since it's benign we won't
554 // bother making it strictly like qtwidgets.
555 if (!parentItem && !m_inDtor)
556 setVisible(false);
557}
558
560{
562}
563
564void View::raiseAndActivate(QQuickItem *item)
565{
566 if (QWindow *w = item->window()) {
567 w->raise();
568 w->requestActivate();
569 }
570}
571
573{
574 raiseAndActivate(this);
575}
576
578{
579 if (QWindow *w = QQuickItem::window())
580 w->requestActivate();
581}
582
584{
585 if (isRootView()) {
586 if (QWindow *w = QQuickItem::window())
587 w->raise();
588 } else if (auto p = QQuickItem::parentItem()) {
589 // It's not a top-level, so just increase its Z-order
590 const auto siblings = p->childItems();
591 QQuickItem *last = siblings.last();
592 if (last != this)
593 stackAfter(last);
594 }
595}
596
597/*static*/ bool View::isRootView(const QQuickItem *item)
598{
599 QQuickItem *parent = item->parentItem();
600 if (!parent)
601 return true;
602
603 if (auto *w = qobject_cast<QQuickWindow *>(item->window())) {
604 if (parent == w->contentItem() || item == w->contentItem())
605 return true;
606 if (auto *qv = qobject_cast<QQuickView *>(item->window())) {
607 if (parent == qv->rootObject() || item == qv->rootObject())
608 return true;
609 }
610 }
611
612 return false;
613}
614
616{
617 return View::isRootView(this);
618}
619
620QQuickView *View::quickView() const
621{
622 return qobject_cast<QQuickView *>(QQuickItem::window());
623}
624
626{
627 return QQuickItem::mapToGlobal(localPt).toPoint();
628}
629
631{
632 return QQuickItem::mapFromGlobal(globalPt).toPoint();
633}
634
636{
637 if (!parent)
638 return {};
639
640 auto parentItem = asQQuickItem(parent);
641 return parentItem->mapFromGlobal(QQuickItem::mapToGlobal(pos)).toPoint();
642}
643
645{
646 if (QWindow *w = QQuickItem::window())
647 w->setOpacity(v);
648}
649
651{
652 if (QWindow *w = QQuickItem::window())
653 w->setTitle(title);
654}
655
656void View::setWindowIcon(const QIcon &icon)
657{
658 if (QWindow *w = QQuickItem::window())
659 w->setIcon(icon);
660}
661
663{
664 if (QWindow *w = QQuickItem::window())
665 return w->isActive();
666
667 return false;
668}
669
671{
672 if (QWindow *w = QQuickItem::window())
673 w->showNormal();
674}
675
677{
678 if (QWindow *w = QQuickItem::window())
679 w->showMinimized();
680}
681
683{
684 if (QWindow *w = QQuickItem::window())
685 w->showMaximized();
686}
687
689{
690 if (QWindow *w = QQuickItem::window())
691 return w->windowStates() & Qt::WindowMinimized;
692
693 return false;
694}
695
697{
698 if (QWindow *w = QQuickItem::window())
699 return w->windowStates() & Qt::WindowMaximized;
700
701 return false;
702}
703
704int View::zOrder() const
705{
706 // Returns the zOrder so we can unit test that raising works in MDI mode.
707 // This is unrelated to QQuickItem::z(), which is always 0 for us.
708 if (auto p = parentItem()) {
709 const auto siblings = p->childItems();
710 return siblings.indexOf(const_cast<QtQuick::View *>(this));
711 }
712
713 return 0;
714}
715
716std::shared_ptr<Core::Window> View::window() const
717{
718 if (QWindow *w = QQuickItem::window()) {
719 auto windowqtquick = new QtQuick::Window(w);
720 return std::shared_ptr<Core::Window>(windowqtquick);
721 }
722
723 return {};
724}
725
726std::shared_ptr<Core::View> View::childViewAt(QPoint p) const
727{
728 auto child = QQuickItem::childAt(p.x(), p.y());
729 return child ? asQQuickWrapper(child) : nullptr;
730}
731
732/*static*/
733std::shared_ptr<Core::View> View::parentViewFor(const QQuickItem *item)
734{
735 auto p = item->parentItem();
736 if (QQuickWindow *window = item->window()) {
737 if (p == window->contentItem()) {
738 // For our purposes, the root view is the one directly below QQuickWindow::contentItem
739 return nullptr;
740 }
741 }
742
743 return p ? asQQuickWrapper(p) : nullptr;
744}
745
746/* static */
747std::shared_ptr<Core::View> View::asQQuickWrapper(QQuickItem *item)
748{
749 return ViewWrapper::create(item);
750}
751
752std::shared_ptr<Core::View> View::parentView() const
753{
754 return parentViewFor(this);
755}
756
757std::shared_ptr<Core::View> View::asWrapper()
758{
759 return ViewWrapper::create(this);
760}
761
763{
764 QQuickItem::grabMouse();
765}
766
768{
769 QQuickItem::ungrabMouse();
770}
771
773{
774 // Not needed for QtQuick
775}
776
778{
779 QQuickItem::setFocus(true, reason);
780 forceActiveFocus(reason);
781}
782
783bool View::hasFocus() const
784{
785 return QQuickItem::hasActiveFocus();
786}
787
789{
790 return m_focusPolicy;
791}
792
794{
795 m_focusPolicy = policy;
796}
797
799{
800 return QQuickItem::objectName();
801}
802
804{
805 if (minSize() != sz) {
806 setProperty("kddockwidgets_min_size", sz);
808 Core::View::d->layoutInvalidated.emit();
809 }
810}
811
812void View::render(QPainter *painter)
813{
814 if (QQuickWindow *w = QQuickItem::window()) {
815 const QImage image = w->grabWindow();
816
817 const QPoint pos = mapToScene({ 0, 0 }).toPoint();
818 const QRect sourceRect { pos * image.devicePixelRatio(), painter->window().size() * image.devicePixelRatio() };
819 painter->drawImage(painter->window(), image, sourceRect);
820 }
821}
822
824{
825 QQuickItem::setCursor(shape);
826}
827
828void View::setMouseTracking(bool enable)
829{
830 m_mouseTrackingEnabled = enable;
831}
832
834{
836 const auto childItems = QQuickItem::childItems();
837 result.reserve(childItems.size());
838 for (QQuickItem *child : childItems) {
839 result << asQQuickWrapper(child);
840 }
841
842 return result;
843}
844
846{
847 if (QWindow *window = QQuickItem::window()) {
848 m_oldWindowState = window->windowState();
849 }
850}
851
853{
855}
856
858{
860}
861
862namespace KDDockWidgets {
863inline QString cleanQRCFilename(const QString &filename)
864{
865 // QFile doesn't understand qrc:/ only :/
866
867 if (filename.startsWith(QStringLiteral("qrc:/")))
868 return filename.right(filename.size() - 3);
869
870 return filename;
871}
872}
873
874QQuickItem *View::createItem(const QString &filename, QQuickItem *parent, QQmlContext *ctx)
875{
876 auto p = parent;
877 QQmlEngine *engine = nullptr;
878 while (p && !engine) {
879 engine = qmlEngine(p);
880 p = p->parentItem();
881 }
882
883 if (!engine)
885
886 if (!engine) {
887 qWarning() << Q_FUNC_INFO << "No engine found";
888 return nullptr;
889 }
890
891 if (!QFile::exists(cleanQRCFilename(filename))) {
892 qWarning() << Q_FUNC_INFO << "File not found" << filename;
893 return nullptr;
894 }
895
896 QQmlComponent component(engine, filename);
897 auto qquickitem = qobject_cast<QQuickItem *>(component.create(ctx));
898 if (!qquickitem) {
899 qWarning() << Q_FUNC_INFO << component.errorString();
900 return nullptr;
901 }
902
903 qquickitem->setParentItem(parent);
904 qquickitem->QObject::setParent(parent);
905
906 return qquickitem;
907}
908
910{
911 QQuickItem::setZ(z);
912}
913
914QQuickItem *View::visualItem() const
915{
916 qWarning() << Q_FUNC_INFO
917 << "Base class called, please implement in your derived class if needed";
918 return nullptr;
919}
920
921QQmlContext *QtQuick::qmlContextFor(QQuickItem *item)
922{
923 while (item) {
924 if (auto ctx = qmlContext(item))
925 return ctx;
926 item = item->parentItem();
927 }
928
929 return nullptr;
930}
931
932#include "View.moc"
Controller *const m_controller
Definition core/View.h:260
virtual bool is(ViewType) const
Returns whether the view is of the specified type Virtual so it can be overridden by ViewWrapper....
virtual void move(int x, int y)=0
void QQUICKITEMgeometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override
Qt::FocusPolicy focusPolicy() const override
bool isExplicitlyHidden() const override
Qt::WindowFlags flags() const override
std::shared_ptr< Core::View > rootView() const override
Returns the top-level gui element which this view is inside It's the root view of the window.
static QQuickItem * createItem(QQmlEngine *engine, const QString &filename, QQmlContext *context=nullptr)
Convenience to create a QQuickItem.
bool isRootView() const override final
bool hasAttribute(Qt::WidgetAttribute attr) const override
void itemChange(QQuickItem::ItemChange, const QQuickItem::ItemChangeData &) override
bool isActiveWindow() const override
Q_INVOKABLE void showMaximized() override
Q_INVOKABLE void showMinimized() override
void render(QPainter *) override
bool eventFilter(QObject *watched, QEvent *ev) override
Q_INVOKABLE void showNormal() override
QPoint mapToGlobal(QPoint localPt) const override
void setMaximumSize(QSize sz) override
void setZOrder(int) override
Sets the z order Not supported on all platforms and only relevant for MDI mode.
void setParent(Core::View *parent) override
void onWindowStateChangeEvent(QWindowStateChangeEvent *)
std::shared_ptr< Core::View > childViewAt(QPoint p) const override
void setMinimumSize(QSize sz) override
void setWindowIcon(const QIcon &icon) override
void setMouseTracking(bool enable) override
void move(int x, int y) override
virtual QQuickItem * visualItem() const
QPoint mapTo(Core::View *parent, QPoint pos) const override
QPoint mapFromGlobal(QPoint globalPt) const override
QRect normalGeometry() const override
void setFocusPolicy(Qt::FocusPolicy) override
static std::shared_ptr< Core::View > asQQuickWrapper(QQuickItem *item)
QString viewName() const override
void setFlag(Qt::WindowType f, bool on=true) override
Q_INVOKABLE void redirectMouseEvents(QQuickItem *from)
QVector< std::shared_ptr< Core::View > > childViews() const override
@Returns a list of child views
std::shared_ptr< Core::View > parentView() const override
Returns the gui element's parent. Like QWidget::parentWidget()
QSize maxSizeHint() const override
void enableAttribute(Qt::WidgetAttribute attr, bool enable=true) override
static void makeItemFillParent(QQuickItem *item)
This is equivalent to "anchors.fill: parent but in C++.
void setCursor(Qt::CursorShape shape) override
void setFocus(Qt::FocusReason reason) override
void setSize(int w, int h) override final
std::shared_ptr< Core::Window > window() const override
Returns the window this view is inside For the Qt frontend, this wraps a QWindow. Like QWidget::windo...
void setWindowTitle(const QString &title) override
View(Core::Controller *controller, Core::ViewType type, QQuickItem *parent=nullptr, Qt::WindowFlags windowFlags={})
void setVisible(bool is) override
static std::shared_ptr< Core::View > parentViewFor(const QQuickItem *)
std::shared_ptr< Core::View > asWrapper() override
Returns this view, but as a wrapper.
void setWindowOpacity(double v) override
ViewType
Each View type also has a specific Controller associated with, except for ViewType::None.
Definition Controller.h:26
DOCKS_EXPORT QQmlContext * qmlContextFor(QQuickItem *)
QQuickItem * asQQuickItem(Core::View *view)
Class to abstract QAction, so code still works with QtQuick and Flutter.
QString cleanQRCFilename(const QString &filename)
bool isAccepted() const const
void ignore()
QEvent::Type type() const const
bool exists() const const
int remove(const Key &key)
qreal devicePixelRatio() const const
Q_OBJECTQ_OBJECT
void installEventFilter(QObject *filterObj)
QVariant property(const char *name) const const
void setParent(QObject *parent)
bool setProperty(const char *name, const QVariant &value)
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags)
QRect window() const const
int x() const const
int y() const const
bool isValid() const const
void setSize(const QSize &size)
QSize size() const const
QSizeF size() const const
QPointF topLeft() const const
QSize boundedTo(const QSize &otherSize) const const
QSize expandedTo(const QSize &otherSize) const const
int height() const const
bool isEmpty() const const
int width() const const
QString right(int n) const const
int size() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
CursorShape
FocusPolicy
FocusReason
WA_Moved
WindowMinimized
typedef WindowFlags
static bool flagsAreTopLevelFlags(Qt::WindowFlags flags)
static QQuickItem * actualParentItem(QQuickItem *candidateParentItem, Qt::WindowFlags flags)
QVariant fromValue(const T &value)
bool isValid() const const
bool toBool() const const
T value() const const
void reserve(int size)

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated by doxygen 1.9.8