KDDockWidgets API Documentation 1.7
Loading...
Searching...
No Matches
Widget_qwidget.cpp
Go to the documentation of this file.
1/*
2 This file is part of KDDockWidgets.
3
4 SPDX-FileCopyrightText: 2020-2023 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 "Widget_qwidget.h"
13#include "Item_p.h"
14
15#include <QDebug>
16#include <QWidget>
17
18using namespace Layouting;
19
21 : Widget(thisWidget)
22 , m_thisWidget(thisWidget)
23{
24}
25
29
31{
32 return m_thisWidget->sizeHint();
33}
34
36{
37 return widgetMinSize(m_thisWidget);
38}
39
41{
42 return widgetMaxSize(m_thisWidget);
43}
44
46{
47 return m_thisWidget->geometry();
48}
49
51{
52 m_thisWidget->setGeometry(rect);
53}
54
56{
57 if (!parent) {
58 m_thisWidget->setParent(nullptr);
59 return;
60 }
61
62 if (auto qwidget = qobject_cast<QWidget *>(parent->asQObject())) {
63 m_thisWidget->setParent(qwidget);
64 } else {
65 qWarning() << Q_FUNC_INFO << "parent is not a widget, you have a bug" << parent->asQObject();
66 Q_ASSERT(false);
67 }
68}
69
71{
72 d << " Dump Start: Host=" << m_thisWidget << rect()
73 << "; dpr=" << m_thisWidget->devicePixelRatio() << ")";
74
75 return d;
76}
77
79{
80 return m_thisWidget->isVisible();
81}
82
83void Widget_qwidget::setVisible(bool is) const
84{
85 m_thisWidget->setVisible(is);
86}
87
88std::unique_ptr<Widget> Widget_qwidget::parentWidget() const
89{
90 if (auto pw = m_thisWidget->parentWidget()) {
91 return std::unique_ptr<Widget>(new Widget_qwidget(pw));
92 }
93
94 return {};
95}
96
98{
99 m_thisWidget->show();
100}
101
103{
104 m_thisWidget->hide();
105}
106
107void Widget_qwidget::move(int x, int y)
108{
109 m_thisWidget->move(x, y);
110}
111
112void Widget_qwidget::setSize(int width, int height)
113{
114 m_thisWidget->resize(QSize(width, height));
115}
116
118{
119 setSize(width, m_thisWidget->height());
120}
121
123{
124 setSize(m_thisWidget->width(), height);
125}
126
128{
129 m_thisWidget->update();
130}
A Layouting::Widget that's deals in QWidget.
A Layouting::Widget that's deals in QWidget Allows to host a QWidget in the layout.
QSize minSize() const override
std::unique_ptr< Widget > parentWidget() const override
Widget_qwidget(QWidget *thisWidget)
void setVisible(bool) const override
void setGeometry(QRect) override
QDebug & dumpDebug(QDebug &) const override
QSize maxSizeHint() const override
void setSize(int width, int height) override
void setParent(Widget *) override
void setWidth(int width) override
bool isVisible() const override
void setHeight(int height) override
QSize sizeHint() const override
void move(int x, int y) override
QRect geometry() const override
An abstraction/wrapper around QWidget, QtQuickItem or anything else.
Definition Widget.h:77
static QSize widgetMaxSize(const T *w)
Definition Widget.h:164
QRect rect() const
Definition Widget.h:117
static QSize widgetMinSize(const T *w)
Definition Widget.h:152
QObject * parent() const
Definition Widget.h:126
int y() const
Definition Widget.h:136
int x() const
Definition Widget.h:131
int devicePixelRatio() const const
void hide()
void move(int x, int y)
QWidget * parentWidget() const const
void resize(int w, int h)
void setGeometry(int x, int y, int w, int h)
void setParent(QWidget *parent)
void show()
void update()
bool isVisible() const const

© 2019-2023 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 on Wed Nov 1 2023 00:02:31 for KDDockWidgets API Documentation by doxygen 1.9.8