summaryrefslogtreecommitdiffstats
path: root/examples/activeqt/hierarchy/objects.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/activeqt/hierarchy/objects.cpp')
-rw-r--r--examples/activeqt/hierarchy/objects.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/examples/activeqt/hierarchy/objects.cpp b/examples/activeqt/hierarchy/objects.cpp
index 1cb59ae..c28cd85 100644
--- a/examples/activeqt/hierarchy/objects.cpp
+++ b/examples/activeqt/hierarchy/objects.cpp
@@ -6,7 +6,17 @@
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
-** You may use this file under the terms of the BSD license as follows:
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -45,16 +55,16 @@
/* Implementation of QParentWidget */
//! [0]
QParentWidget::QParentWidget(QWidget *parent)
-: QWidget(parent)
+: QWidget(parent),
+ m_vbox(new QVBoxLayout(this))
{
- vbox = new QVBoxLayout(this);
}
//! [0] //! [1]
void QParentWidget::createSubWidget(const QString &name)
{
QSubWidget *sw = new QSubWidget(this, name);
- vbox->addWidget(sw);
+ m_vbox->addWidget(sw);
sw->setLabel(name);
sw->show();
}
@@ -62,7 +72,7 @@ void QParentWidget::createSubWidget(const QString &name)
//! [1] //! [2]
QSubWidget *QParentWidget::subWidget(const QString &name)
{
- return findChild<QSubWidget*>(name);
+ return findChild<QSubWidget *>(name);
}
//! [2]
@@ -81,27 +91,27 @@ QSubWidget::QSubWidget(QWidget *parent, const QString &name)
void QSubWidget::setLabel(const QString &text)
{
- lbl = text;
+ m_label = text;
setObjectName(text);
update();
}
QString QSubWidget::label() const
{
- return lbl;
+ return m_label;
}
QSize QSubWidget::sizeHint() const
{
QFontMetrics fm(font());
- return QSize(fm.width(lbl), fm.height());
+ return QSize(fm.width(m_label), fm.height());
}
void QSubWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(palette().text().color());
- painter.drawText(rect(), Qt::AlignCenter, lbl);
+ painter.drawText(rect(), Qt::AlignCenter, m_label);
//! [3] //! [4]
}
//! [4]