summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp7
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp2
-rw-r--r--examples/corelib/tools/tools.pro1
-rw-r--r--examples/dbus/complexpingpong/complexpingpong.pro1
-rw-r--r--examples/dbus/pingpong/pingpong.pro1
-rw-r--r--examples/network/multistreamclient/chatconsumer.h4
-rw-r--r--examples/network/multistreamclient/movieconsumer.h6
-rw-r--r--examples/network/multistreamclient/timeconsumer.h6
-rw-r--r--examples/network/multistreamserver/chatprovider.h6
-rw-r--r--examples/network/multistreamserver/server.h2
-rw-r--r--examples/network/multistreamserver/timeprovider.h2
-rw-r--r--examples/network/torrent/mainwindow.cpp18
-rw-r--r--examples/opengl/computegles31/glwindow.h2
-rw-r--r--examples/opengl/qopenglwindow/background_renderer.cpp6
-rw-r--r--examples/widgets/desktop/desktop.pro1
-rw-r--r--examples/widgets/doc/src/wiggly.qdoc8
-rw-r--r--examples/widgets/effects/fademessage/fademessage.cpp2
-rw-r--r--examples/widgets/itemviews/fetchmore/filelistmodel.cpp3
-rw-r--r--examples/widgets/itemviews/flattreeview/flattreeview.pro7
-rw-r--r--examples/widgets/itemviews/flattreeview/main.cpp84
-rw-r--r--examples/widgets/itemviews/itemviews.pro1
-rw-r--r--examples/widgets/itemviews/puzzle/piecesmodel.cpp10
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.cpp2
-rw-r--r--examples/widgets/mainwindows/mainwindow/colorswatch.h4
-rw-r--r--examples/widgets/mainwindows/mainwindow/main.cpp2
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp2
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.h2
-rw-r--r--examples/widgets/mainwindows/mainwindow/toolbar.cpp37
-rw-r--r--examples/widgets/mainwindows/sdi/main.cpp2
-rw-r--r--examples/widgets/painting/deform/pathdeform.cpp2
-rw-r--r--examples/widgets/painting/shared/arthurstyle.cpp4
-rw-r--r--examples/widgets/statemachine/rogue/window.cpp4
-rw-r--r--examples/widgets/tools/codecs/previewform.h2
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/charactermap/characterwidget.cpp2
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/codeeditor/codeeditor.cpp2
-rw-r--r--examples/widgets/widgets/icons/iconpreviewarea.cpp2
-rw-r--r--examples/widgets/widgets/icons/iconpreviewarea.h2
-rw-r--r--examples/widgets/widgets/icons/iconsizespinbox.h2
-rw-r--r--examples/widgets/widgets/icons/imagedelegate.h2
-rw-r--r--examples/widgets/widgets/tablet/mainwindow.cpp2
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.cpp9
-rw-r--r--examples/widgets/widgets/tablet/tabletcanvas.h2
-rw-r--r--examples/widgets/widgets/wiggly/wigglywidget.cpp4
-rw-r--r--examples/xml/dombookmarks/xbeltree.h2
46 files changed, 190 insertions, 88 deletions
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
index 1d36b7e5ef..bc7ec17d1c 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
@@ -72,8 +72,8 @@
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, m_model(new MimetypeModel(this))
- , m_treeView(new QTreeView)
- , m_detailsText(new QTextEdit)
+ , m_treeView(new QTreeView(this))
+ , m_detailsText(new QTextEdit(this))
, m_findIndex(0)
{
setWindowTitle(tr("Qt Mime Database Browser"));
@@ -97,9 +97,8 @@ MainWindow::MainWindow(QWidget *parent)
menuBar()->addMenu(tr("&About"))->addAction(tr("&About Qt"), qApp, &QApplication::aboutQt);
- QSplitter *centralSplitter = new QSplitter;
+ QSplitter *centralSplitter = new QSplitter(this);
setCentralWidget(centralSplitter);
- m_treeView = new QTreeView;
m_treeView->setUniformRowHeights(true);
m_treeView->setModel(m_model);
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
index fd0060d8a9..b3e4af5dc8 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
@@ -126,7 +126,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
QString text = tr("Use mouse wheel or the '+' and '-' keys to zoom. "
"Press and hold left mouse button to scroll.");
QFontMetrics metrics = painter.fontMetrics();
- int textWidth = metrics.width(text);
+ int textWidth = metrics.horizontalAdvance(text);
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 127));
diff --git a/examples/corelib/tools/tools.pro b/examples/corelib/tools/tools.pro
index 36fa776980..6fb4a1214f 100644
--- a/examples/corelib/tools/tools.pro
+++ b/examples/corelib/tools/tools.pro
@@ -1,7 +1,6 @@
requires(qtHaveModule(widgets))
TEMPLATE = subdirs
-CONFIG += ordered
SUBDIRS = contiguouscache \
customtype \
customtypesending
diff --git a/examples/dbus/complexpingpong/complexpingpong.pro b/examples/dbus/complexpingpong/complexpingpong.pro
index cd618d549d..c30286b732 100644
--- a/examples/dbus/complexpingpong/complexpingpong.pro
+++ b/examples/dbus/complexpingpong/complexpingpong.pro
@@ -1,4 +1,3 @@
TEMPLATE = subdirs
-CONFIG += ordered
win32:CONFIG += console
SUBDIRS = complexping.pro complexpong.pro
diff --git a/examples/dbus/pingpong/pingpong.pro b/examples/dbus/pingpong/pingpong.pro
index 07fca74c9a..654574c76d 100644
--- a/examples/dbus/pingpong/pingpong.pro
+++ b/examples/dbus/pingpong/pingpong.pro
@@ -1,4 +1,3 @@
TEMPLATE = subdirs
-CONFIG += ordered
win32:CONFIG += console
SUBDIRS = ping.pro pong.pro
diff --git a/examples/network/multistreamclient/chatconsumer.h b/examples/network/multistreamclient/chatconsumer.h
index 9e12f99359..e10c0d7850 100644
--- a/examples/network/multistreamclient/chatconsumer.h
+++ b/examples/network/multistreamclient/chatconsumer.h
@@ -64,8 +64,8 @@ class ChatConsumer : public Consumer
public:
explicit ChatConsumer(QObject *parent = nullptr);
- QWidget *widget() Q_DECL_OVERRIDE;
- void readDatagram(const QByteArray &ba) Q_DECL_OVERRIDE;
+ QWidget *widget() override;
+ void readDatagram(const QByteArray &ba) override;
private slots:
void returnPressed();
diff --git a/examples/network/multistreamclient/movieconsumer.h b/examples/network/multistreamclient/movieconsumer.h
index 74321a8505..3f78bf2060 100644
--- a/examples/network/multistreamclient/movieconsumer.h
+++ b/examples/network/multistreamclient/movieconsumer.h
@@ -63,9 +63,9 @@ class MovieConsumer : public Consumer
public:
explicit MovieConsumer(QObject *parent = nullptr);
- QWidget *widget() Q_DECL_OVERRIDE;
- void readDatagram(const QByteArray &ba) Q_DECL_OVERRIDE;
- void serverDisconnected() Q_DECL_OVERRIDE;
+ QWidget *widget() override;
+ void readDatagram(const QByteArray &ba) override;
+ void serverDisconnected() override;
private:
QLabel *label;
diff --git a/examples/network/multistreamclient/timeconsumer.h b/examples/network/multistreamclient/timeconsumer.h
index 3faa4a6b1a..84a7796699 100644
--- a/examples/network/multistreamclient/timeconsumer.h
+++ b/examples/network/multistreamclient/timeconsumer.h
@@ -64,9 +64,9 @@ class TimeConsumer : public Consumer
public:
explicit TimeConsumer(QObject *parent = nullptr);
- QWidget *widget() Q_DECL_OVERRIDE;
- void readDatagram(const QByteArray &ba) Q_DECL_OVERRIDE;
- void serverDisconnected() Q_DECL_OVERRIDE;
+ QWidget *widget() override;
+ void readDatagram(const QByteArray &ba) override;
+ void serverDisconnected() override;
private slots:
void timerTick();
diff --git a/examples/network/multistreamserver/chatprovider.h b/examples/network/multistreamserver/chatprovider.h
index b6ff61a917..c52fa89240 100644
--- a/examples/network/multistreamserver/chatprovider.h
+++ b/examples/network/multistreamserver/chatprovider.h
@@ -59,9 +59,9 @@ class ChatProvider : public Provider
public:
explicit ChatProvider(QObject *parent = nullptr);
- void readDatagram(QSctpSocket &from, const QByteArray &ba) Q_DECL_OVERRIDE;
- void newConnection(QSctpSocket &client) Q_DECL_OVERRIDE;
- void clientDisconnected(QSctpSocket &client) Q_DECL_OVERRIDE;
+ void readDatagram(QSctpSocket &from, const QByteArray &ba) override;
+ void newConnection(QSctpSocket &client) override;
+ void clientDisconnected(QSctpSocket &client) override;
};
#endif
diff --git a/examples/network/multistreamserver/server.h b/examples/network/multistreamserver/server.h
index d9a38e61a4..2380d6ffd6 100644
--- a/examples/network/multistreamserver/server.h
+++ b/examples/network/multistreamserver/server.h
@@ -72,7 +72,7 @@ public:
virtual ~Server();
public slots:
- int exec() Q_DECL_OVERRIDE;
+ int exec() override;
private slots:
void newConnection();
diff --git a/examples/network/multistreamserver/timeprovider.h b/examples/network/multistreamserver/timeprovider.h
index f99cdbc717..a4d08fd67c 100644
--- a/examples/network/multistreamserver/timeprovider.h
+++ b/examples/network/multistreamserver/timeprovider.h
@@ -59,7 +59,7 @@ class TimeProvider : public Provider
public:
explicit TimeProvider(QObject *parent = nullptr);
- void readDatagram(QSctpSocket &from, const QByteArray &ba) Q_DECL_OVERRIDE;
+ void readDatagram(QSctpSocket &from, const QByteArray &ba) override;
};
#endif
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index efdf187174..f80c2c6975 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -129,12 +129,12 @@ MainWindow::MainWindow(QWidget *parent)
// Set header resize modes and initial section sizes
QFontMetrics fm = fontMetrics();
QHeaderView *header = torrentView->header();
- header->resizeSection(0, fm.width("typical-name-for-a-torrent.torrent"));
- header->resizeSection(1, fm.width(headers.at(1) + " "));
- header->resizeSection(2, fm.width(headers.at(2) + " "));
- header->resizeSection(3, qMax(fm.width(headers.at(3) + " "), fm.width(" 1234.0 KB/s ")));
- header->resizeSection(4, qMax(fm.width(headers.at(4) + " "), fm.width(" 1234.0 KB/s ")));
- header->resizeSection(5, qMax(fm.width(headers.at(5) + " "), fm.width(tr("Downloading") + " ")));
+ header->resizeSection(0, fm.horizontalAdvance("typical-name-for-a-torrent.torrent"));
+ header->resizeSection(1, fm.horizontalAdvance(headers.at(1) + " "));
+ header->resizeSection(2, fm.horizontalAdvance(headers.at(2) + " "));
+ header->resizeSection(3, qMax(fm.horizontalAdvance(headers.at(3) + " "), fm.horizontalAdvance(" 1234.0 KB/s ")));
+ header->resizeSection(4, qMax(fm.horizontalAdvance(headers.at(4) + " "), fm.horizontalAdvance(" 1234.0 KB/s ")));
+ header->resizeSection(5, qMax(fm.horizontalAdvance(headers.at(5) + " "), fm.horizontalAdvance(tr("Downloading") + " ")));
// Create common actions
QAction *newTorrentAction = new QAction(QIcon(":/icons/bottom.png"), tr("Add &new torrent"), this);
@@ -174,14 +174,14 @@ MainWindow::MainWindow(QWidget *parent)
bottomBar->addWidget(new QLabel(tr("Max download:")));
bottomBar->addWidget(downloadLimitSlider);
bottomBar->addWidget((downloadLimitLabel = new QLabel(tr("0 KB/s"))));
- downloadLimitLabel->setFixedSize(QSize(fm.width(tr("99999 KB/s")), fm.lineSpacing()));
+ downloadLimitLabel->setFixedSize(QSize(fm.horizontalAdvance(tr("99999 KB/s")), fm.lineSpacing()));
bottomBar->addSeparator();
uploadLimitSlider = new QSlider(Qt::Horizontal);
uploadLimitSlider->setRange(0, 1000);
bottomBar->addWidget(new QLabel(tr("Max upload:")));
bottomBar->addWidget(uploadLimitSlider);
bottomBar->addWidget((uploadLimitLabel = new QLabel(tr("0 KB/s"))));
- uploadLimitLabel->setFixedSize(QSize(fm.width(tr("99999 KB/s")), fm.lineSpacing()));
+ uploadLimitLabel->setFixedSize(QSize(fm.horizontalAdvance(tr("99999 KB/s")), fm.lineSpacing()));
#ifdef Q_OS_OSX
setUnifiedTitleAndToolBarOnMac(true);
@@ -220,7 +220,7 @@ QSize MainWindow::sizeHint() const
// Add up the sizes of all header sections. The last section is
// stretched, so its size is relative to the size of the width;
// instead of counting it, we count the size of its largest value.
- int width = fontMetrics().width(tr("Downloading") + " ");
+ int width = fontMetrics().horizontalAdvance(tr("Downloading") + " ");
for (int i = 0; i < header->count() - 1; ++i)
width += header->sectionSize(i);
diff --git a/examples/opengl/computegles31/glwindow.h b/examples/opengl/computegles31/glwindow.h
index 877f7b732e..f243858a45 100644
--- a/examples/opengl/computegles31/glwindow.h
+++ b/examples/opengl/computegles31/glwindow.h
@@ -86,7 +86,7 @@ public:
void setBlurRadius(float blurRadius);
protected:
- void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *e) override;
void setAnimating(bool animate);
private:
diff --git a/examples/opengl/qopenglwindow/background_renderer.cpp b/examples/opengl/qopenglwindow/background_renderer.cpp
index d57198444e..cba4ae1f2f 100644
--- a/examples/opengl/qopenglwindow/background_renderer.cpp
+++ b/examples/opengl/qopenglwindow/background_renderer.cpp
@@ -146,7 +146,7 @@ void FragmentToy::draw(const QSize &windowSize)
m_fragment_shader.reset(new QOpenGLShader(QOpenGLShader::Fragment));
if (!m_fragment_shader->compileSourceCode(data)) {
qWarning() << "Failed to compile fragment shader:" << m_fragment_shader->log();
- m_fragment_shader.reset(Q_NULLPTR);
+ m_fragment_shader.reset(nullptr);
}
} else {
qWarning() << "Unknown error, no fragment shader";
@@ -198,14 +198,14 @@ void FragmentToy::fileChanged(const QString &path)
m_recompile_shaders = true;
if (m_program) {
m_program->removeShader(m_fragment_shader.data());
- m_fragment_shader.reset(Q_NULLPTR);
+ m_fragment_shader.reset(nullptr);
}
}
} else {
m_recompile_shaders = true;
if (m_program) {
m_program->removeShader(m_fragment_shader.data());
- m_fragment_shader.reset(Q_NULLPTR);
+ m_fragment_shader.reset(nullptr);
}
}
}
diff --git a/examples/widgets/desktop/desktop.pro b/examples/widgets/desktop/desktop.pro
index db518c1c7a..4c9d0e2cec 100644
--- a/examples/widgets/desktop/desktop.pro
+++ b/examples/widgets/desktop/desktop.pro
@@ -1,3 +1,2 @@
TEMPLATE = subdirs
-CONFIG += ordered
SUBDIRS = screenshot systray
diff --git a/examples/widgets/doc/src/wiggly.qdoc b/examples/widgets/doc/src/wiggly.qdoc
index f330b016df..d70d609e2b 100644
--- a/examples/widgets/doc/src/wiggly.qdoc
+++ b/examples/widgets/doc/src/wiggly.qdoc
@@ -143,10 +143,10 @@
position on the wiggly line based on \c step. In addition, \c x
is incremented by the character's width.
- For simplicity, we assume that QFontMetrics::width(\c text)
- returns the sum of the individual character widths
- (QFontMetrics::width(\c text[i])). In practice, this is not
- always the case because QFontMetrics::width(\c text) also takes
+ For simplicity, we assume that QFontMetrics::horizontalAdvance(\c text)
+ returns the sum of the individual character advances
+ (QFontMetrics::horizontalAdvance(\c text[i])). In practice, this is not
+ always the case because QFontMetrics::horizontalAdvance(\c text) also takes
into account the kerning between certain letters (e.g., 'A' and
'V'). The result is that the text isn't perfectly centered. You
can verify this by typing "AVAVAVAVAVAV" in the line edit.
diff --git a/examples/widgets/effects/fademessage/fademessage.cpp b/examples/widgets/effects/fademessage/fademessage.cpp
index d91293288c..9943147bb7 100644
--- a/examples/widgets/effects/fademessage/fademessage.cpp
+++ b/examples/widgets/effects/fademessage/fademessage.cpp
@@ -108,7 +108,7 @@ void FadeMessage::setupScene()
int fh = fontMetrics.height();
QString sceneText = "Qt Everywhere!";
- int sceneTextWidth = fontMetrics.width(sceneText);
+ int sceneTextWidth = fontMetrics.horizontalAdvance(sceneText);
QGraphicsRectItem *block = m_scene.addRect(50, 300, sceneTextWidth, fh + 3);
block->setPen(Qt::NoPen);
diff --git a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
index cd21712e04..086d45eca3 100644
--- a/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
+++ b/examples/widgets/itemviews/fetchmore/filelistmodel.cpp
@@ -103,6 +103,9 @@ void FileListModel::fetchMore(const QModelIndex & /* index */)
int remainder = fileList.size() - fileCount;
int itemsToFetch = qMin(100, remainder);
+ if (itemsToFetch <= 0)
+ return;
+
beginInsertRows(QModelIndex(), fileCount, fileCount+itemsToFetch-1);
fileCount += itemsToFetch;
diff --git a/examples/widgets/itemviews/flattreeview/flattreeview.pro b/examples/widgets/itemviews/flattreeview/flattreeview.pro
new file mode 100644
index 0000000000..05a6573d33
--- /dev/null
+++ b/examples/widgets/itemviews/flattreeview/flattreeview.pro
@@ -0,0 +1,7 @@
+QT += widgets
+
+SOURCES = main.cpp
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/widgets/itemviews/flattreeview
+INSTALLS += target
diff --git a/examples/widgets/itemviews/flattreeview/main.cpp b/examples/widgets/itemviews/flattreeview/main.cpp
new file mode 100644
index 0000000000..e9bbb3fab1
--- /dev/null
+++ b/examples/widgets/itemviews/flattreeview/main.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** 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
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ main.cpp
+
+ A simple example that shows a multi-column list using QTreeView.
+ The data is not a tree, so the first column was made movable.
+*/
+
+#include <QApplication>
+#include <QHeaderView>
+#include <QStandardItemModel>
+#include <QTreeView>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QStandardItemModel model(4, 2);
+ QTreeView treeView;
+ treeView.setModel(&model);
+ treeView.setRootIsDecorated(false);
+ treeView.header()->setFirstSectionMovable(true);
+ treeView.header()->setStretchLastSection(true);
+
+ for (int row = 0; row < 4; ++row) {
+ for (int column = 0; column < 2; ++column) {
+ QModelIndex index = model.index(row, column, QModelIndex());
+ model.setData(index, QVariant((row + 1) * (column + 1)));
+ }
+ }
+
+ treeView.setWindowTitle(QObject::tr("Flat Tree View"));
+ treeView.show();
+ return app.exec();
+}
diff --git a/examples/widgets/itemviews/itemviews.pro b/examples/widgets/itemviews/itemviews.pro
index 787217a8e8..75307bd74e 100644
--- a/examples/widgets/itemviews/itemviews.pro
+++ b/examples/widgets/itemviews/itemviews.pro
@@ -8,6 +8,7 @@ SUBDIRS = addressbook \
dirview \
editabletreemodel \
fetchmore \
+ flattreeview \
frozencolumn \
interview \
pixelator \
diff --git a/examples/widgets/itemviews/puzzle/piecesmodel.cpp b/examples/widgets/itemviews/puzzle/piecesmodel.cpp
index f0649d3776..28b46836f4 100644
--- a/examples/widgets/itemviews/puzzle/piecesmodel.cpp
+++ b/examples/widgets/itemviews/puzzle/piecesmodel.cpp
@@ -203,10 +203,12 @@ Qt::DropActions PiecesModel::supportedDropActions() const
void PiecesModel::addPieces(const QPixmap& pixmap)
{
- beginRemoveRows(QModelIndex(), 0, 24);
- pixmaps.clear();
- locations.clear();
- endRemoveRows();
+ if (!pixmaps.isEmpty()) {
+ beginRemoveRows(QModelIndex(), 0, pixmaps.size() - 1);
+ pixmaps.clear();
+ locations.clear();
+ endRemoveRows();
+ }
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
QPixmap pieceImage = pixmap.copy(x*m_PieceSize, y*m_PieceSize, m_PieceSize, m_PieceSize);
diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.cpp b/examples/widgets/mainwindows/mainwindow/colorswatch.cpp
index c47b80275f..720f9a2085 100644
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.cpp
+++ b/examples/widgets/mainwindows/mainwindow/colorswatch.cpp
@@ -468,7 +468,7 @@ static ColorSwatch *findByName(const QMainWindow *mainWindow, const QString &nam
if (name == dock->objectName())
return dock;
}
- return Q_NULLPTR;
+ return nullptr;
}
void ColorSwatch::splitInto(QAction *action)
diff --git a/examples/widgets/mainwindows/mainwindow/colorswatch.h b/examples/widgets/mainwindows/mainwindow/colorswatch.h
index ec9d9e7372..7f73e46f31 100644
--- a/examples/widgets/mainwindows/mainwindow/colorswatch.h
+++ b/examples/widgets/mainwindows/mainwindow/colorswatch.h
@@ -62,7 +62,7 @@ class ColorSwatch : public QDockWidget
Q_OBJECT
public:
- explicit ColorSwatch(const QString &colorName, QMainWindow *parent = Q_NULLPTR, Qt::WindowFlags flags = 0);
+ explicit ColorSwatch(const QString &colorName, QMainWindow *parent = nullptr, Qt::WindowFlags flags = 0);
void setCustomSizeHint(const QSize &size);
QMenu *colorSwatchMenu() const { return menu; }
@@ -128,7 +128,7 @@ class BlueTitleBar : public QWidget
{
Q_OBJECT
public:
- explicit BlueTitleBar(QWidget *parent = Q_NULLPTR);
+ explicit BlueTitleBar(QWidget *parent = nullptr);
QSize sizeHint() const override { return minimumSizeHint(); }
QSize minimumSizeHint() const override;
diff --git a/examples/widgets/mainwindows/mainwindow/main.cpp b/examples/widgets/mainwindows/mainwindow/main.cpp
index c78022e392..b82f67b361 100644
--- a/examples/widgets/mainwindows/mainwindow/main.cpp
+++ b/examples/widgets/mainwindows/mainwindow/main.cpp
@@ -175,6 +175,8 @@ static ParseCommandLineArgumentsResult
int main(int argc, char **argv)
{
+ QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication app(argc, argv);
MainWindow::CustomSizeHintMap customSizeHints;
switch (parseCustomSizeHints(QCoreApplication::arguments(), &customSizeHints)) {
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
index afceddfca1..b2c5ccc473 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
@@ -382,7 +382,7 @@ void MainWindow::switchLayoutDirection()
class CreateDockWidgetDialog : public QDialog
{
public:
- explicit CreateDockWidgetDialog(QWidget *parent = Q_NULLPTR);
+ explicit CreateDockWidgetDialog(QWidget *parent = nullptr);
QString enteredObjectName() const { return m_objectName->text(); }
Qt::DockWidgetArea location() const;
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.h b/examples/widgets/mainwindows/mainwindow/mainwindow.h
index af4f1f5745..9b1af6df80 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.h
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.h
@@ -64,7 +64,7 @@ public:
typedef QMap<QString, QSize> CustomSizeHintMap;
explicit MainWindow(const CustomSizeHintMap &customSizeHints,
- QWidget *parent = Q_NULLPTR,
+ QWidget *parent = nullptr,
Qt::WindowFlags flags = 0);
public slots:
diff --git a/examples/widgets/mainwindows/mainwindow/toolbar.cpp b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
index 814cfc7f4d..7c96f5b1be 100644
--- a/examples/widgets/mainwindows/mainwindow/toolbar.cpp
+++ b/examples/widgets/mainwindows/mainwindow/toolbar.cpp
@@ -62,10 +62,10 @@
#include <stdlib.h>
-static QPixmap genIcon(const QSize &iconSize, const QString &, const QColor &color)
+static QPixmap genIcon(const QSize &iconSize, const QString &, const QColor &color, qreal pixelRatio)
{
- int w = iconSize.width();
- int h = iconSize.height();
+ int w = qRound(iconSize.width() * pixelRatio);
+ int h = qRound(iconSize.height() * pixelRatio);
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
image.fill(0);
@@ -75,38 +75,41 @@ static QPixmap genIcon(const QSize &iconSize, const QString &, const QColor &col
extern void render_qt_text(QPainter *, int, int, const QColor &);
render_qt_text(&p, w, h, color);
- return QPixmap::fromImage(image, Qt::DiffuseDither | Qt::DiffuseAlphaDither);
+ QPixmap pm = QPixmap::fromImage(image, Qt::DiffuseDither | Qt::DiffuseAlphaDither);
+ pm.setDevicePixelRatio(pixelRatio);
+ return pm;
}
-static QPixmap genIcon(const QSize &iconSize, int number, const QColor &color)
-{ return genIcon(iconSize, QString::number(number), color); }
+static QPixmap genIcon(const QSize &iconSize, int number, const QColor &color, qreal pixelRatio)
+{ return genIcon(iconSize, QString::number(number), color, pixelRatio); }
ToolBar::ToolBar(const QString &title, QWidget *parent)
: QToolBar(parent)
- , spinbox(Q_NULLPTR)
- , spinboxAction(Q_NULLPTR)
+ , spinbox(nullptr)
+ , spinboxAction(nullptr)
{
setWindowTitle(title);
setObjectName(title);
setIconSize(QSize(32, 32));
+ qreal dpr = devicePixelRatioF();
menu = new QMenu("One", this);
- menu->setIcon(genIcon(iconSize(), 1, Qt::black));
- menu->addAction(genIcon(iconSize(), "A", Qt::blue), "A");
- menu->addAction(genIcon(iconSize(), "B", Qt::blue), "B");
- menu->addAction(genIcon(iconSize(), "C", Qt::blue), "C");
+ menu->setIcon(genIcon(iconSize(), 1, Qt::black, dpr));
+ menu->addAction(genIcon(iconSize(), "A", Qt::blue, dpr), "A");
+ menu->addAction(genIcon(iconSize(), "B", Qt::blue, dpr), "B");
+ menu->addAction(genIcon(iconSize(), "C", Qt::blue, dpr), "C");
addAction(menu->menuAction());
- QAction *two = addAction(genIcon(iconSize(), 2, Qt::white), "Two");
+ QAction *two = addAction(genIcon(iconSize(), 2, Qt::white, dpr), "Two");
QFont boldFont;
boldFont.setBold(true);
two->setFont(boldFont);
- addAction(genIcon(iconSize(), 3, Qt::red), "Three");
- addAction(genIcon(iconSize(), 4, Qt::green), "Four");
- addAction(genIcon(iconSize(), 5, Qt::blue), "Five");
- addAction(genIcon(iconSize(), 6, Qt::yellow), "Six");
+ addAction(genIcon(iconSize(), 3, Qt::red, dpr), "Three");
+ addAction(genIcon(iconSize(), 4, Qt::green, dpr), "Four");
+ addAction(genIcon(iconSize(), 5, Qt::blue, dpr), "Five");
+ addAction(genIcon(iconSize(), 6, Qt::yellow, dpr), "Six");
orderAction = new QAction(this);
orderAction->setText(tr("Order Items in Tool Bar"));
connect(orderAction, &QAction::triggered, this, &ToolBar::order);
diff --git a/examples/widgets/mainwindows/sdi/main.cpp b/examples/widgets/mainwindows/sdi/main.cpp
index bed990d34d..6e29fafd6f 100644
--- a/examples/widgets/mainwindows/sdi/main.cpp
+++ b/examples/widgets/mainwindows/sdi/main.cpp
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
parser.addPositionalArgument("file", "The file(s) to open.");
parser.process(app);
- MainWindow *mainWin = Q_NULLPTR;
+ MainWindow *mainWin = nullptr;
foreach (const QString &file, parser.positionalArguments()) {
MainWindow *newWin = new MainWindow(file);
newWin->tile(mainWin);
diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp
index 3f72a33902..490a8508d6 100644
--- a/examples/widgets/painting/deform/pathdeform.cpp
+++ b/examples/widgets/painting/deform/pathdeform.cpp
@@ -364,7 +364,7 @@ void PathDeformRenderer::setText(const QString &text)
path.addText(advance, f, text.mid(i, 1));
m_pathBounds |= path.boundingRect();
m_paths << path;
- advance += QPointF(fm.width(text.mid(i, 1)), 0);
+ advance += QPointF(fm.horizontalAdvance(text.mid(i, 1)), 0);
}
} else {
QPainterPath path;
diff --git a/examples/widgets/painting/shared/arthurstyle.cpp b/examples/widgets/painting/shared/arthurstyle.cpp
index 484eaec31c..f4fc76bda6 100644
--- a/examples/widgets/painting/shared/arthurstyle.cpp
+++ b/examples/widgets/painting/shared/arthurstyle.cpp
@@ -294,7 +294,7 @@ void ArthurStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
QPixmap titleLeft = cached(":res/images/title_cap_left.png");
QPixmap titleRight = cached(":res/images/title_cap_right.png");
QPixmap titleStretch = cached(":res/images/title_stretch.png");
- int txt_width = groupBox->fontMetrics.width(groupBox->text) + 20;
+ int txt_width = groupBox->fontMetrics.horizontalAdvance(groupBox->text) + 20;
painter->drawPixmap(r.center().x() - txt_width/2, 0, titleLeft);
QRect tileRect = subControlRect(control, groupBox, SC_GroupBoxLabel, widget);
painter->drawTiledPixmap(tileRect, titleStretch);
@@ -385,7 +385,7 @@ QRect ArthurStyle::subControlRect(ComplexControl control, const QStyleOptionComp
QPixmap titleLeft = cached(":res/images/title_cap_left.png");
QPixmap titleRight = cached(":res/images/title_cap_right.png");
QPixmap titleStretch = cached(":res/images/title_stretch.png");
- int txt_width = group->fontMetrics.width(group->text) + 20;
+ int txt_width = group->fontMetrics.horizontalAdvance(group->text) + 20;
rect = QRect(group->rect.center().x() - txt_width/2 + titleLeft.width(), 0,
txt_width - titleLeft.width() - titleRight.width(),
titleStretch.height());
diff --git a/examples/widgets/statemachine/rogue/window.cpp b/examples/widgets/statemachine/rogue/window.cpp
index 3515138382..059fbf1003 100644
--- a/examples/widgets/statemachine/rogue/window.cpp
+++ b/examples/widgets/statemachine/rogue/window.cpp
@@ -98,7 +98,7 @@ void Window::paintEvent(QPaintEvent * /* event */)
QFontMetrics metrics(font());
QPainter painter(this);
int fontHeight = metrics.height();
- int fontWidth = metrics.width('X');
+ int fontWidth = metrics.horizontalAdvance('X');
int yPos = fontHeight;
int xPos;
@@ -177,7 +177,7 @@ QSize Window::sizeHint() const
{
QFontMetrics metrics(font());
- return QSize(metrics.width('X') * WIDTH, metrics.height() * (HEIGHT + 1));
+ return QSize(metrics.horizontalAdvance('X') * WIDTH, metrics.height() * (HEIGHT + 1));
}
//![2]
diff --git a/examples/widgets/tools/codecs/previewform.h b/examples/widgets/tools/codecs/previewform.h
index 1846b976de..6335b6539f 100644
--- a/examples/widgets/tools/codecs/previewform.h
+++ b/examples/widgets/tools/codecs/previewform.h
@@ -69,7 +69,7 @@ class PreviewForm : public QDialog
Q_OBJECT
public:
- explicit PreviewForm(QWidget *parent = Q_NULLPTR);
+ explicit PreviewForm(QWidget *parent = nullptr);
void setCodecList(const QList<QTextCodec *> &list);
void setEncodedData(const QByteArray &data);
diff --git a/examples/widgets/tools/settingseditor/mainwindow.cpp b/examples/widgets/tools/settingseditor/mainwindow.cpp
index ab9837c513..a7a1e9b415 100644
--- a/examples/widgets/tools/settingseditor/mainwindow.cpp
+++ b/examples/widgets/tools/settingseditor/mainwindow.cpp
@@ -56,7 +56,7 @@
MainWindow::MainWindow()
: settingsTree(new SettingsTree)
- , locationDialog(Q_NULLPTR)
+ , locationDialog(nullptr)
{
setCentralWidget(settingsTree);
diff --git a/examples/widgets/widgets/charactermap/characterwidget.cpp b/examples/widgets/widgets/charactermap/characterwidget.cpp
index 55d45501f1..5bab921516 100644
--- a/examples/widgets/widgets/charactermap/characterwidget.cpp
+++ b/examples/widgets/widgets/charactermap/characterwidget.cpp
@@ -181,7 +181,7 @@ void CharacterWidget::paintEvent(QPaintEvent *event)
if (key == lastKey)
painter.fillRect(column*squareSize + 1, row*squareSize + 1, squareSize, squareSize, QBrush(Qt::red));
- painter.drawText(column*squareSize + (squareSize / 2) - fontMetrics.width(QChar(key))/2,
+ painter.drawText(column*squareSize + (squareSize / 2) - fontMetrics.horizontalAdvance(QChar(key))/2,
row*squareSize + 4 + fontMetrics.ascent(),
QString(QChar(key)));
}
diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp
index 5f17128a2f..d3ac55483c 100644
--- a/examples/widgets/widgets/charactermap/mainwindow.cpp
+++ b/examples/widgets/widgets/charactermap/mainwindow.cpp
@@ -244,7 +244,7 @@ void MainWindow::updateClipboard()
class FontInfoDialog : public QDialog
{
public:
- explicit FontInfoDialog(QWidget *parent = Q_NULLPTR);
+ explicit FontInfoDialog(QWidget *parent = nullptr);
private:
QString text() const;
diff --git a/examples/widgets/widgets/codeeditor/codeeditor.cpp b/examples/widgets/widgets/codeeditor/codeeditor.cpp
index 69974e72be..7e56a75294 100644
--- a/examples/widgets/widgets/codeeditor/codeeditor.cpp
+++ b/examples/widgets/widgets/codeeditor/codeeditor.cpp
@@ -79,7 +79,7 @@ int CodeEditor::lineNumberAreaWidth()
++digits;
}
- int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
+ int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
return space;
}
diff --git a/examples/widgets/widgets/icons/iconpreviewarea.cpp b/examples/widgets/widgets/icons/iconpreviewarea.cpp
index 35379610c5..9cb54c47f6 100644
--- a/examples/widgets/widgets/icons/iconpreviewarea.cpp
+++ b/examples/widgets/widgets/icons/iconpreviewarea.cpp
@@ -190,7 +190,7 @@ QLabel *IconPreviewArea::createPixmapLabel()
//! [5]
void IconPreviewArea::updatePixmapLabels()
{
- QWindow *window = Q_NULLPTR;
+ QWindow *window = nullptr;
if (const QWidget *nativeParent = nativeParentWidget())
window = nativeParent->windowHandle();
for (int column = 0; column < NumModes; ++column) {
diff --git a/examples/widgets/widgets/icons/iconpreviewarea.h b/examples/widgets/widgets/icons/iconpreviewarea.h
index 3ebb9ed3ce..6ea35a5230 100644
--- a/examples/widgets/widgets/icons/iconpreviewarea.h
+++ b/examples/widgets/widgets/icons/iconpreviewarea.h
@@ -66,7 +66,7 @@ class IconPreviewArea : public QWidget
Q_OBJECT
public:
- explicit IconPreviewArea(QWidget *parent = Q_NULLPTR);
+ explicit IconPreviewArea(QWidget *parent = nullptr);
void setIcon(const QIcon &icon);
void setSize(const QSize &size);
diff --git a/examples/widgets/widgets/icons/iconsizespinbox.h b/examples/widgets/widgets/icons/iconsizespinbox.h
index 96a56e75c9..87415ac5d6 100644
--- a/examples/widgets/widgets/icons/iconsizespinbox.h
+++ b/examples/widgets/widgets/icons/iconsizespinbox.h
@@ -59,7 +59,7 @@ class IconSizeSpinBox : public QSpinBox
Q_OBJECT
public:
- explicit IconSizeSpinBox(QWidget *parent = Q_NULLPTR);
+ explicit IconSizeSpinBox(QWidget *parent = nullptr);
int valueFromText(const QString &text) const override;
QString textFromValue(int value) const override;
diff --git a/examples/widgets/widgets/icons/imagedelegate.h b/examples/widgets/widgets/icons/imagedelegate.h
index 928085d85b..3b76b78339 100644
--- a/examples/widgets/widgets/icons/imagedelegate.h
+++ b/examples/widgets/widgets/icons/imagedelegate.h
@@ -59,7 +59,7 @@ class ImageDelegate : public QItemDelegate
Q_OBJECT
public:
- explicit ImageDelegate(QObject *parent = Q_NULLPTR);
+ explicit ImageDelegate(QObject *parent = nullptr);
//! [0]
//! [1]
diff --git a/examples/widgets/widgets/tablet/mainwindow.cpp b/examples/widgets/widgets/tablet/mainwindow.cpp
index feae16dd83..994666d4de 100644
--- a/examples/widgets/widgets/tablet/mainwindow.cpp
+++ b/examples/widgets/widgets/tablet/mainwindow.cpp
@@ -55,7 +55,7 @@
//! [0]
MainWindow::MainWindow(TabletCanvas *canvas)
- : m_canvas(canvas), m_colorDialog(Q_NULLPTR)
+ : m_canvas(canvas), m_colorDialog(nullptr)
{
createMenus();
setWindowTitle(tr("Tablet Example"));
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.cpp b/examples/widgets/widgets/tablet/tabletcanvas.cpp
index 4b11568dfe..73678ab754 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/widgets/tablet/tabletcanvas.cpp
@@ -55,7 +55,7 @@
//! [0]
TabletCanvas::TabletCanvas()
- : QWidget(Q_NULLPTR)
+ : QWidget(nullptr)
, m_alphaChannelValuator(TangentialPressureValuator)
, m_colorSaturationValuator(NoValuator)
, m_lineWidthValuator(PressureValuator)
@@ -119,12 +119,12 @@ void TabletCanvas::tabletEvent(QTabletEvent *event)
case QEvent::TabletRelease:
if (m_deviceDown && event->buttons() == Qt::NoButton)
m_deviceDown = false;
+ update();
break;
default:
break;
}
event->accept();
- update();
}
//! [3]
@@ -154,6 +154,7 @@ void TabletCanvas::paintEvent(QPaintEvent *)
//! [5]
void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
{
+ static qreal maxPenRadius = pressureToWidth(1.0);
painter.setRenderHint(QPainter::Antialiasing);
switch (event->device()) {
@@ -169,6 +170,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
painter.setBrush(grad);
qreal radius = grad.radius();
painter.drawEllipse(event->posF(), radius, radius);
+ update(QRect(event->pos() - QPoint(radius, radius), QSize(radius * 2, radius * 2)));
}
break;
case QTabletEvent::RotationStylus:
@@ -188,6 +190,7 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
poly << event->posF() - brushAdjust;
poly << event->posF() + brushAdjust;
painter.drawConvexPolygon(poly);
+ update(poly.boundingRect().toRect());
}
break;
//! [6]
@@ -217,6 +220,8 @@ void TabletCanvas::paintPixmap(QPainter &painter, QTabletEvent *event)
case QTabletEvent::Stylus:
painter.setPen(m_pen);
painter.drawLine(lastPoint.pos, event->posF());
+ update(QRect(lastPoint.pos.toPoint(), event->pos()).normalized()
+ .adjusted(-maxPenRadius, -maxPenRadius, maxPenRadius, maxPenRadius));
break;
}
}
diff --git a/examples/widgets/widgets/tablet/tabletcanvas.h b/examples/widgets/widgets/tablet/tabletcanvas.h
index a1b31c65bf..671d5376f8 100644
--- a/examples/widgets/widgets/tablet/tabletcanvas.h
+++ b/examples/widgets/widgets/tablet/tabletcanvas.h
@@ -103,7 +103,7 @@ private:
void initPixmap();
void paintPixmap(QPainter &painter, QTabletEvent *event);
Qt::BrushStyle brushPattern(qreal value);
- qreal pressureToWidth(qreal pressure);
+ static qreal pressureToWidth(qreal pressure);
void updateBrush(const QTabletEvent *event);
void updateCursor(const QTabletEvent *event);
diff --git a/examples/widgets/widgets/wiggly/wigglywidget.cpp b/examples/widgets/widgets/wiggly/wigglywidget.cpp
index 9dfd43ff77..1b8f3cffad 100644
--- a/examples/widgets/widgets/wiggly/wigglywidget.cpp
+++ b/examples/widgets/widgets/wiggly/wigglywidget.cpp
@@ -77,7 +77,7 @@ void WigglyWidget::paintEvent(QPaintEvent * /* event */)
};
QFontMetrics metrics(font());
- int x = (width() - metrics.width(text)) / 2;
+ int x = (width() - metrics.horizontalAdvance(text)) / 2;
int y = (height() + metrics.ascent() - metrics.descent()) / 2;
QColor color;
//! [2]
@@ -91,7 +91,7 @@ void WigglyWidget::paintEvent(QPaintEvent * /* event */)
painter.setPen(color);
painter.drawText(x, y - ((sineTable[index] * metrics.height()) / 400),
QString(text[i]));
- x += metrics.width(text[i]);
+ x += metrics.horizontalAdvance(text[i]);
}
}
//! [4]
diff --git a/examples/xml/dombookmarks/xbeltree.h b/examples/xml/dombookmarks/xbeltree.h
index f6c7ef8bfe..c58e1148ff 100644
--- a/examples/xml/dombookmarks/xbeltree.h
+++ b/examples/xml/dombookmarks/xbeltree.h
@@ -67,7 +67,7 @@ public:
protected:
#if !defined(QT_NO_CONTEXTMENU) && !defined(QT_NO_CLIPBOARD)
- void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *event) override;
#endif
private slots: