From c2751b1d664748cfbd05d2e397f95f2cc0bec13f Mon Sep 17 00:00:00 2001 From: Andre de la Rocha Date: Mon, 21 Aug 2017 13:23:48 +0200 Subject: Active Qt Examples: Brush up to C++ 11 Use nullptr, member initialization, new connect syntax, QStringLiteral, etc. Change-Id: Ia79473ca302216f91eec6a32f670cf606761ed0d Reviewed-by: Michael Winkelmann Reviewed-by: Friedemann Kleint --- examples/activeqt/hierarchy/objects.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'examples/activeqt/hierarchy/objects.cpp') diff --git a/examples/activeqt/hierarchy/objects.cpp b/examples/activeqt/hierarchy/objects.cpp index 1cb59ae..c0d0f0d 100644 --- a/examples/activeqt/hierarchy/objects.cpp +++ b/examples/activeqt/hierarchy/objects.cpp @@ -45,16 +45,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 +62,7 @@ void QParentWidget::createSubWidget(const QString &name) //! [1] //! [2] QSubWidget *QParentWidget::subWidget(const QString &name) { - return findChild(name); + return findChild(name); } //! [2] @@ -81,27 +81,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] -- cgit v1.2.1 From a07f521f9bfa535ad18cbdd93e228276133ff4d9 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 28 Sep 2017 13:26:23 +0200 Subject: Fix outdated BSD license header Use new version with commercial exception. Change-Id: I20b377176e99b80db47f41596d20192ae7d5564f Reviewed-by: Friedemann Kleint --- examples/activeqt/hierarchy/objects.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'examples/activeqt/hierarchy/objects.cpp') diff --git a/examples/activeqt/hierarchy/objects.cpp b/examples/activeqt/hierarchy/objects.cpp index c0d0f0d..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 -- cgit v1.2.1