Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_gui_kernel_qlayout.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4//! [0]
5static void paintLayout(QPainter *painter, QLayoutItem *item)
6{
7 QLayout *layout = item->layout();
8 if (layout) {
9 for (int i = 0; i < layout->count(); ++i)
10 paintLayout(painter, layout->itemAt(i));
11 }
12 painter->drawRect(item->geometry());
13}
14
15void MyWidget::paintEvent(QPaintEvent *)
16{
17 QPainter painter(this);
18 if (layout())
19 paintLayout(&painter, layout());
20}
21//! [0]
22
23
24//! [1]
26while ((child = layout->takeAt(0)) != nullptr) {
27 ...
28 delete child->widget(); // delete the widget
29 delete child; // delete the layout item
30}
31//! [1]
QLayoutItem * child
[0]
static void paintLayout(QPainter *painter, QLayoutItem *item)
[0]