From 879f98106d5974ef19c96cb228ca032701b94556 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Aug 2017 11:19:21 +0200 Subject: Revamp QtWidgets/DragAndDrop examples to C++11 Introduce nullptr and replace foreach with new C++11 range based for loops. Minor fixups of signals, file dialog usage. Apply the same changes to the ItemViews/puzzle example since it shares parts of the code with DragAndDrop/puzzle. Make some changes to both examples to that the diff of the two becomes small for easier comparison. Task-number: QTBUG-60635 Change-Id: I8af824229ebac24d6ec151eae92176d227695490 Reviewed-by: Venugopal Shivashankar Reviewed-by: Gatis Paeglis --- examples/widgets/draganddrop/dropsite/droparea.h | 4 ++-- examples/widgets/draganddrop/dropsite/dropsitewindow.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'examples/widgets/draganddrop/dropsite') diff --git a/examples/widgets/draganddrop/dropsite/droparea.h b/examples/widgets/draganddrop/dropsite/droparea.h index 5b6e209dfa..ab1de8ea44 100644 --- a/examples/widgets/draganddrop/dropsite/droparea.h +++ b/examples/widgets/draganddrop/dropsite/droparea.h @@ -63,13 +63,13 @@ class DropArea : public QLabel Q_OBJECT public: - DropArea(QWidget *parent = 0); + explicit DropArea(QWidget *parent = nullptr); public slots: void clear(); signals: - void changed(const QMimeData *mimeData = 0); + void changed(const QMimeData *mimeData = nullptr); //! [DropArea header part1] //! [DropArea header part2] diff --git a/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp b/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp index dc865ac171..28a42ee614 100644 --- a/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp +++ b/examples/widgets/draganddrop/dropsite/dropsitewindow.cpp @@ -88,8 +88,8 @@ DropSiteWindow::DropSiteWindow() buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); - connect(quitButton, &QAbstractButton::pressed, this, &QWidget::close); - connect(clearButton, &QAbstractButton::pressed, dropArea, &DropArea::clear); + connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close); + connect(clearButton, &QAbstractButton::clicked, dropArea, &DropArea::clear); //! [constructor part4] //! [constructor part5] @@ -113,7 +113,7 @@ void DropSiteWindow::updateFormatsTable(const QMimeData *mimeData) //! [updateFormatsTable() part1] //! [updateFormatsTable() part2] - foreach (QString format, mimeData->formats()) { + for (const QString &format : mimeData->formats()) { QTableWidgetItem *formatItem = new QTableWidgetItem(format); formatItem->setFlags(Qt::ItemIsEnabled); formatItem->setTextAlignment(Qt::AlignTop | Qt::AlignLeft); -- cgit v1.2.3