KDDockWidgets API Documentation  1.5
Widget_qwidget.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2020-2022 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 
18 using namespace Layouting;
19 
21  : Widget(thisWidget)
22  , m_thisWidget(thisWidget)
23 {
24 }
25 
27 {
28 }
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 
83 void Widget_qwidget::setVisible(bool is) const
84 {
85  m_thisWidget->setVisible(is);
86 }
87 
88 std::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 
107 void Widget_qwidget::move(int x, int y)
108 {
109  m_thisWidget->move(x, y);
110 }
111 
112 void 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 }
Layouting::Widget_qwidget::show
void show() override
Definition: Widget_qwidget.cpp:97
QPaintDevice::devicePixelRatio
int devicePixelRatio() const const
Layouting::Widget::widgetMaxSize
static QSize widgetMaxSize(const T *w)
Definition: Widget.h:164
QWidget::setParent
void setParent(QWidget *parent)
Layouting::Widget_qwidget::setParent
void setParent(Widget *) override
Definition: Widget_qwidget.cpp:55
Layouting::Widget::widgetMinSize
static QSize widgetMinSize(const T *w)
Definition: Widget.h:152
Layouting::Widget_qwidget::parentWidget
std::unique_ptr< Widget > parentWidget() const override
Definition: Widget_qwidget.cpp:88
QRect
Widget_qwidget.h
A Layouting::Widget that's deals in QWidget.
Layouting::Widget_qwidget::move
void move(int x, int y) override
Definition: Widget_qwidget.cpp:107
QWidget::update
void update()
QWidget
Layouting::Widget::y
int y() const
Definition: Widget.h:138
QSize
QDebug
Layouting::Widget_qwidget::dumpDebug
QDebug & dumpDebug(QDebug &) const override
Definition: Widget_qwidget.cpp:70
Layouting::Widget_qwidget::setHeight
void setHeight(int height) override
Definition: Widget_qwidget.cpp:122
QWidget::hide
void hide()
QWidget::isVisible
bool isVisible() const const
Layouting::Widget_qwidget::update
void update() override
Definition: Widget_qwidget.cpp:127
Layouting::Widget_qwidget::setWidth
void setWidth(int width) override
Definition: Widget_qwidget.cpp:117
Layouting::Widget::x
int x() const
Definition: Widget.h:133
Layouting::Widget
An abstraction/wrapper around QWidget, QtQuickItem or anything else.
Definition: Widget.h:79
Layouting::Widget_qwidget::hide
void hide() override
Definition: Widget_qwidget.cpp:102
Layouting::Widget_qwidget::Widget_qwidget
Widget_qwidget(QWidget *thisWidget)
Definition: Widget_qwidget.cpp:20
QWidget::show
void show()
Layouting::Widget_qwidget::geometry
QRect geometry() const override
Definition: Widget_qwidget.cpp:45
Layouting::Widget::rect
QRect rect() const
Definition: Widget.h:119
QWidget::setGeometry
void setGeometry(int x, int y, int w, int h)
QWidget::resize
void resize(int w, int h)
QWidget::height
height
Layouting::Widget_qwidget::~Widget_qwidget
~Widget_qwidget() override
Definition: Widget_qwidget.cpp:26
QWidget::sizeHint
sizeHint
QWidget::move
void move(int x, int y)
Layouting::Widget_qwidget::setVisible
void setVisible(bool) const override
Definition: Widget_qwidget.cpp:83
QWidget::geometry
geometry
QWidget::width
width
Layouting
Definition: FrameworkWidgetFactory.h:32
Layouting::Widget_qwidget::setSize
void setSize(int width, int height) override
Definition: Widget_qwidget.cpp:112
Layouting::Widget_qwidget::setGeometry
void setGeometry(QRect) override
Definition: Widget_qwidget.cpp:50
Layouting::Widget_qwidget::sizeHint
QSize sizeHint() const override
Definition: Widget_qwidget.cpp:30
QWidget::parentWidget
QWidget * parentWidget() const const
Layouting::Widget_qwidget::maxSizeHint
QSize maxSizeHint() const override
Definition: Widget_qwidget.cpp:40
Layouting::Widget_qwidget::minSize
QSize minSize() const override
Definition: Widget_qwidget.cpp:35
Layouting::Widget_qwidget::isVisible
bool isVisible() const override
Definition: Widget_qwidget.cpp:78
Layouting::Widget::parent
QObject * parent() const
Definition: Widget.h:128

© 2019-2022 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 Mon Mar 7 2022 02:01:21 for KDDockWidgets API Documentation by doxygen 1.8.20