summaryrefslogtreecommitdiff
path: root/examples/activeqt/hierarchy/objects.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-30 08:42:53 +0100
committerLiang Qi <liang.qi@qt.io>2017-10-30 08:48:01 +0100
commitc9acfe0bc8dbaec1065614fa2039ebe7e05b4bda (patch)
tree6ced392965bf01be840da14e7f1606b0b5b2293d /examples/activeqt/hierarchy/objects.cpp
parentf263d206341472e23e0e1ad536faa1b0a22286c0 (diff)
parentcacf666f95df9790cebf5d5cdb0609cee257fab3 (diff)
downloadqtactiveqt-c9acfe0bc8dbaec1065614fa2039ebe7e05b4bda.tar.gz
Merge remote-tracking branch 'origin/5.9' into 5.10v5.10.0-beta4
Conflicts: .qmake.conf Change-Id: Ie457478a64a28434afb3361dfc6f9478dd9c58bd
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]