From 5d82cbcfc30a01b489bdaa18a8ed9395b69212c7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 27 Jan 2020 23:50:33 +0100 Subject: Doc: Specify install path for Vulkan examples Vulkan examples, although part of the Qt GUI documentation project, live under their own directory under /examples. Mark the correct install path for these using the \meta command. Fixes: QTBUG-81360 Change-Id: I0b98a19bf56d5b1953dbd90c0d5103be9041689a Reviewed-by: Paul Wicking --- examples/vulkan/doc/src/hellovulkancubes.qdoc | 1 + examples/vulkan/doc/src/hellovulkantexture.qdoc | 1 + examples/vulkan/doc/src/hellovulkantriangle.qdoc | 1 + examples/vulkan/doc/src/hellovulkanwidget.qdoc | 1 + examples/vulkan/doc/src/hellovulkanwindow.qdoc | 1 + 5 files changed, 5 insertions(+) (limited to 'examples') diff --git a/examples/vulkan/doc/src/hellovulkancubes.qdoc b/examples/vulkan/doc/src/hellovulkancubes.qdoc index 8fa3243024..f6160a5083 100644 --- a/examples/vulkan/doc/src/hellovulkancubes.qdoc +++ b/examples/vulkan/doc/src/hellovulkancubes.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkancubes + \meta installpath vulkan \title Hello Vulkan Cubes Example \ingroup examples-vulkan \brief Shows the basics of using QVulkanWindow. diff --git a/examples/vulkan/doc/src/hellovulkantexture.qdoc b/examples/vulkan/doc/src/hellovulkantexture.qdoc index 4284e4a05c..968c560236 100644 --- a/examples/vulkan/doc/src/hellovulkantexture.qdoc +++ b/examples/vulkan/doc/src/hellovulkantexture.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkantexture + \meta installpath vulkan \ingroup examples-vulkan \title Hello Vulkan Texture Vulkan Example \brief Shows the basics of rendering with textures in a QVulkanWindow. diff --git a/examples/vulkan/doc/src/hellovulkantriangle.qdoc b/examples/vulkan/doc/src/hellovulkantriangle.qdoc index 57793cf25a..f030d61578 100644 --- a/examples/vulkan/doc/src/hellovulkantriangle.qdoc +++ b/examples/vulkan/doc/src/hellovulkantriangle.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkantriangle + \meta installpath vulkan \ingroup examples-vulkan \title Hello Vulkan Triangle Example \brief Shows the basics of rendering with QVulkanWindow and the Vulkan API. diff --git a/examples/vulkan/doc/src/hellovulkanwidget.qdoc b/examples/vulkan/doc/src/hellovulkanwidget.qdoc index b5ad43ba2a..b1fb52ee85 100644 --- a/examples/vulkan/doc/src/hellovulkanwidget.qdoc +++ b/examples/vulkan/doc/src/hellovulkanwidget.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkanwidget + \meta installpath vulkan \ingroup examples-vulkan \title Hello Vulkan Widget Example \brief Shows the usage of QVulkanWindow in QWidget applications. diff --git a/examples/vulkan/doc/src/hellovulkanwindow.qdoc b/examples/vulkan/doc/src/hellovulkanwindow.qdoc index a9682b7e90..e1e95a0952 100644 --- a/examples/vulkan/doc/src/hellovulkanwindow.qdoc +++ b/examples/vulkan/doc/src/hellovulkanwindow.qdoc @@ -27,6 +27,7 @@ /*! \example hellovulkanwindow + \meta installpath vulkan \title Hello Vulkan Window Example \ingroup examples-vulkan \brief Shows the basics of using QVulkanWindow. -- cgit v1.2.3 From 2130d282b1a2671049c90dd4e99e512b8009de9a Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 23 Jan 2020 18:21:58 +0100 Subject: Change examples and snippets to pass QDate and QTime by value They're value types, so we should show them being used as such. Change-Id: If9f0c366fac66306b7861f04e2f047540d444acc Reviewed-by: Christian Ehrlicher --- examples/embedded/flightinfo/flightinfo.cpp | 4 ++-- examples/sql/books/initdb.h | 4 ++-- .../itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp | 8 ++++---- .../itemviews/customsortfiltermodel/mysortfilterproxymodel.h | 8 ++++---- examples/widgets/widgets/calendarwidget/window.cpp | 6 +++--- examples/widgets/widgets/calendarwidget/window.h | 7 ++++--- 6 files changed, 19 insertions(+), 18 deletions(-) (limited to 'examples') diff --git a/examples/embedded/flightinfo/flightinfo.cpp b/examples/embedded/flightinfo/flightinfo.cpp index f46fc9693f..f7df368dd7 100644 --- a/examples/embedded/flightinfo/flightinfo.cpp +++ b/examples/embedded/flightinfo/flightinfo.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. @@ -198,7 +198,7 @@ private slots: public slots: - void request(const QString &flightCode, const QDate &date) { + void request(const QString &flightCode, QDate date) { setWindowTitle("Loading..."); diff --git a/examples/sql/books/initdb.h b/examples/sql/books/initdb.h index 773e3fb74c..e1f690a234 100644 --- a/examples/sql/books/initdb.h +++ b/examples/sql/books/initdb.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the demonstration applications of the Qt Toolkit. @@ -71,7 +71,7 @@ QVariant addGenre(QSqlQuery &q, const QString &name) return q.lastInsertId(); } -QVariant addAuthor(QSqlQuery &q, const QString &name, const QDate &birthdate) +QVariant addAuthor(QSqlQuery &q, const QString &name, QDate birthdate) { q.addBindValue(name); q.addBindValue(birthdate); diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp index 4753d04d9b..430a086fd6 100644 --- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp +++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -60,7 +60,7 @@ MySortFilterProxyModel::MySortFilterProxyModel(QObject *parent) //! [0] //! [1] -void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date) +void MySortFilterProxyModel::setFilterMinimumDate(QDate date) { minDate = date; invalidateFilter(); @@ -68,7 +68,7 @@ void MySortFilterProxyModel::setFilterMinimumDate(const QDate &date) //! [1] //! [2] -void MySortFilterProxyModel::setFilterMaximumDate(const QDate &date) +void MySortFilterProxyModel::setFilterMaximumDate(QDate date) { maxDate = date; invalidateFilter(); @@ -122,7 +122,7 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left, //! [5] //! [6] //! [7] -bool MySortFilterProxyModel::dateInRange(const QDate &date) const +bool MySortFilterProxyModel::dateInRange(QDate date) const { return (!minDate.isValid() || date > minDate) && (!maxDate.isValid() || date < maxDate); diff --git a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h index e2aff3c829..5fdabbd5df 100644 --- a/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h +++ b/examples/widgets/itemviews/customsortfiltermodel/mysortfilterproxymodel.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -63,17 +63,17 @@ public: MySortFilterProxyModel(QObject *parent = 0); QDate filterMinimumDate() const { return minDate; } - void setFilterMinimumDate(const QDate &date); + void setFilterMinimumDate(QDate date); QDate filterMaximumDate() const { return maxDate; } - void setFilterMaximumDate(const QDate &date); + void setFilterMaximumDate(QDate date); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; bool lessThan(const QModelIndex &left, const QModelIndex &right) const override; private: - bool dateInRange(const QDate &date) const; + bool dateInRange(QDate date) const; QDate minDate; QDate maxDate; diff --git a/examples/widgets/widgets/calendarwidget/window.cpp b/examples/widgets/widgets/calendarwidget/window.cpp index b8a3d03552..ae10223dd4 100644 --- a/examples/widgets/widgets/calendarwidget/window.cpp +++ b/examples/widgets/widgets/calendarwidget/window.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -126,7 +126,7 @@ void Window::selectedDateChanged() //! [2] //! [3] -void Window::minimumDateChanged(const QDate &date) +void Window::minimumDateChanged(QDate date) { calendar->setMinimumDate(date); maximumDateEdit->setDate(calendar->maximumDate()); @@ -134,7 +134,7 @@ void Window::minimumDateChanged(const QDate &date) //! [3] //! [4] -void Window::maximumDateChanged(const QDate &date) +void Window::maximumDateChanged(QDate date) { calendar->setMaximumDate(date); minimumDateEdit->setDate(calendar->minimumDate()); diff --git a/examples/widgets/widgets/calendarwidget/window.h b/examples/widgets/widgets/calendarwidget/window.h index 83ea494fc2..1b673b8ce0 100644 --- a/examples/widgets/widgets/calendarwidget/window.h +++ b/examples/widgets/widgets/calendarwidget/window.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -52,6 +52,7 @@ #define WINDOW_H #include +#include QT_BEGIN_NAMESPACE class QCalendarWidget; @@ -79,8 +80,8 @@ private slots: void horizontalHeaderChanged(int index); void verticalHeaderChanged(int index); void selectedDateChanged(); - void minimumDateChanged(const QDate &date); - void maximumDateChanged(const QDate &date); + void minimumDateChanged(QDate date); + void maximumDateChanged(QDate date); void weekdayFormatChanged(); void weekendFormatChanged(); void reformatHeaders(); -- cgit v1.2.3 From c7f59cad196dae2ee83e2073e546428695f0e1f0 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Wed, 29 Jan 2020 19:58:01 +0100 Subject: Examples: fix compile without printsupport Checking for QT_CONFIG(printdialog) is not enough when printsupport is completely disabled since then the macro will throw an error. Therefore add an additional check 'defined(QT_PRINTSUPPORT_LIB)' before using the QT_CONFIG macro. Fixes: QTBUG-81626 Change-Id: Ie9898f057cdd6bf9daf4ba9135987cb6e901e7bf Reviewed-by: Friedemann Kleint --- examples/widgets/dialogs/licensewizard/licensewizard.cpp | 2 +- examples/widgets/graphicsview/chip/view.cpp | 2 +- examples/widgets/itemviews/pixelator/mainwindow.cpp | 2 +- examples/widgets/mainwindows/dockwidgets/mainwindow.cpp | 2 +- examples/widgets/richtext/orderform/mainwindow.cpp | 2 +- examples/widgets/richtext/textedit/textedit.cpp | 2 +- examples/widgets/touch/fingerpaint/scribblearea.cpp | 2 +- examples/widgets/tutorials/notepad/notepad.cpp | 4 ++-- examples/widgets/widgets/imageviewer/imageviewer.cpp | 2 +- examples/widgets/widgets/scribble/scribblearea.cpp | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/widgets/dialogs/licensewizard/licensewizard.cpp b/examples/widgets/dialogs/licensewizard/licensewizard.cpp index c082afa876..2eaadd1cba 100644 --- a/examples/widgets/dialogs/licensewizard/licensewizard.cpp +++ b/examples/widgets/dialogs/licensewizard/licensewizard.cpp @@ -369,7 +369,7 @@ void ConclusionPage::setVisible(bool visible) void ConclusionPage::printButtonClicked() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer; QPrintDialog dialog(&printer, this); if (dialog.exec()) diff --git a/examples/widgets/graphicsview/chip/view.cpp b/examples/widgets/graphicsview/chip/view.cpp index 21998dc2df..d6fec778c2 100644 --- a/examples/widgets/graphicsview/chip/view.cpp +++ b/examples/widgets/graphicsview/chip/view.cpp @@ -264,7 +264,7 @@ void View::toggleAntialiasing() void View::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer; QPrintDialog dialog(&printer, this); if (dialog.exec() == QDialog::Accepted) { diff --git a/examples/widgets/itemviews/pixelator/mainwindow.cpp b/examples/widgets/itemviews/pixelator/mainwindow.cpp index f6b67e4dba..abd4a8b1ab 100644 --- a/examples/widgets/itemviews/pixelator/mainwindow.cpp +++ b/examples/widgets/itemviews/pixelator/mainwindow.cpp @@ -167,7 +167,7 @@ void MainWindow::openImage(const QString &fileName) void MainWindow::printImage() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) if (model->rowCount(QModelIndex())*model->columnCount(QModelIndex()) > 90000) { QMessageBox::StandardButton answer; answer = QMessageBox::question(this, tr("Large Image Size"), diff --git a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp index a62765cdab..dba4a081df 100644 --- a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp +++ b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp @@ -128,7 +128,7 @@ void MainWindow::newLetter() //! [3] void MainWindow::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QTextDocument *document = textEdit->document(); QPrinter printer; diff --git a/examples/widgets/richtext/orderform/mainwindow.cpp b/examples/widgets/richtext/orderform/mainwindow.cpp index 0b6a2cac6c..ee6758c9cb 100644 --- a/examples/widgets/richtext/orderform/mainwindow.cpp +++ b/examples/widgets/richtext/orderform/mainwindow.cpp @@ -248,7 +248,7 @@ void MainWindow::openDialog() //! [17] void MainWindow::printFile() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QTextEdit *editor = static_cast(letters->currentWidget()); //! [18] QPrinter printer; diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index 85fb83ab89..f99fa306df 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -545,7 +545,7 @@ bool TextEdit::fileSaveAs() void TextEdit::filePrint() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer(QPrinter::HighResolution); QPrintDialog *dlg = new QPrintDialog(&printer, this); if (textEdit->textCursor().hasSelection()) diff --git a/examples/widgets/touch/fingerpaint/scribblearea.cpp b/examples/widgets/touch/fingerpaint/scribblearea.cpp index 0b0c4476d9..e490495cd9 100644 --- a/examples/widgets/touch/fingerpaint/scribblearea.cpp +++ b/examples/widgets/touch/fingerpaint/scribblearea.cpp @@ -170,7 +170,7 @@ void ScribbleArea::resizeImage(QImage *image, const QSize &newSize) //! [21] void ScribbleArea::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer(QPrinter::HighResolution); QPrintDialog printDialog(&printer, this); diff --git a/examples/widgets/tutorials/notepad/notepad.cpp b/examples/widgets/tutorials/notepad/notepad.cpp index 2ccd6501a1..5fd0d69cea 100644 --- a/examples/widgets/tutorials/notepad/notepad.cpp +++ b/examples/widgets/tutorials/notepad/notepad.cpp @@ -92,7 +92,7 @@ Notepad::Notepad(QWidget *parent) : connect(ui->actionAbout, &QAction::triggered, this, &Notepad::about); // Disable menu actions for unavailable features -#if !QT_CONFIG(printer) +#if !defined(QT_PRINTSUPPORT_LIB) || !QT_CONFIG(printer) ui->actionPrint->setEnabled(false); #endif @@ -171,7 +171,7 @@ void Notepad::saveAs() void Notepad::print() { -#if QT_CONFIG(printer) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) QPrinter printDev; #if QT_CONFIG(printdialog) QPrintDialog dialog(&printDev, this); diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 83cf8bb7bc..70a4cda984 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -201,7 +201,7 @@ void ImageViewer::print() //! [5] //! [6] { Q_ASSERT(imageLabel->pixmap()); -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) //! [6] //! [7] QPrintDialog dialog(&printer, this); //! [7] //! [8] diff --git a/examples/widgets/widgets/scribble/scribblearea.cpp b/examples/widgets/widgets/scribble/scribblearea.cpp index 75371b523f..d3937f90d8 100644 --- a/examples/widgets/widgets/scribble/scribblearea.cpp +++ b/examples/widgets/widgets/scribble/scribblearea.cpp @@ -210,7 +210,7 @@ void ScribbleArea::resizeImage(QImage *image, const QSize &newSize) //! [21] void ScribbleArea::print() { -#if QT_CONFIG(printdialog) +#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printdialog) QPrinter printer(QPrinter::HighResolution); QPrintDialog printDialog(&printer, this); -- cgit v1.2.3 From b90eaa3bb516f00feaa5ee2bf4f0dd6fe4ec0d9a Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Fri, 31 Jan 2020 19:55:52 +0800 Subject: Examples: Replace deprecated QLabel API Task-number: QTBUG-48701 Change-Id: I6fc875a35dfc3bf4d906d0f0e495c18ef566d1e1 Reviewed-by: Friedemann Kleint Reviewed-by: Paul Wicking --- examples/widgets/desktop/screenshot/screenshot.cpp | 2 +- examples/widgets/doc/src/imageviewer.qdoc | 4 ++-- examples/widgets/draganddrop/draggableicons/dragwidget.cpp | 2 +- examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp | 2 +- examples/widgets/widgets/imageviewer/imageviewer.cpp | 12 ++++++------ 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp index ce5597bbdd..d0a849e0b8 100644 --- a/examples/widgets/desktop/screenshot/screenshot.cpp +++ b/examples/widgets/desktop/screenshot/screenshot.cpp @@ -109,7 +109,7 @@ void Screenshot::resizeEvent(QResizeEvent * /* event */) { QSize scaledSize = originalPixmap.size(); scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio); - if (!screenshotLabel->pixmap() || scaledSize != screenshotLabel->pixmap()->size()) + if (scaledSize != screenshotLabel->pixmap(Qt::ReturnByValue).size()) updateScreenshotLabel(); } //! [1] diff --git a/examples/widgets/doc/src/imageviewer.qdoc b/examples/widgets/doc/src/imageviewer.qdoc index 91b6385356..8cf8c2489e 100644 --- a/examples/widgets/doc/src/imageviewer.qdoc +++ b/examples/widgets/doc/src/imageviewer.qdoc @@ -175,8 +175,8 @@ will expand to \code - if (!imageLabel->pixmap()) - qFatal("ASSERT: "imageLabel->pixmap()" in file ..."); + if (imageLabel->pixmap(Qt::ReturnByValue).isNull()) + qFatal("ASSERT: "imageLabel->pixmap(Qt::ReturnByValue).isNull()" in file ..."); \endcode In release mode, the macro simply disappear. The mode can be set diff --git a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp index 2019645c1d..00671dcf7e 100644 --- a/examples/widgets/draganddrop/draggableicons/dragwidget.cpp +++ b/examples/widgets/draganddrop/draggableicons/dragwidget.cpp @@ -142,7 +142,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event) if (!child) return; - QPixmap pixmap = *child->pixmap(); + QPixmap pixmap = child->pixmap(Qt::ReturnByValue); QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); diff --git a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp index 451b53f623..4fbc6d3fd9 100644 --- a/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp +++ b/examples/widgets/draganddrop/fridgemagnets/dragwidget.cpp @@ -208,7 +208,7 @@ void DragWidget::mousePressEvent(QMouseEvent *event) //! [16] QDrag *drag = new QDrag(this); drag->setMimeData(mimeData); - drag->setPixmap(*child->pixmap()); + drag->setPixmap(child->pixmap(Qt::ReturnByValue)); drag->setHotSpot(hotSpot); child->hide(); diff --git a/examples/widgets/widgets/imageviewer/imageviewer.cpp b/examples/widgets/widgets/imageviewer/imageviewer.cpp index 83cf8bb7bc..1efaad0082 100644 --- a/examples/widgets/widgets/imageviewer/imageviewer.cpp +++ b/examples/widgets/widgets/imageviewer/imageviewer.cpp @@ -200,19 +200,20 @@ void ImageViewer::saveAs() void ImageViewer::print() //! [5] //! [6] { - Q_ASSERT(imageLabel->pixmap()); + Q_ASSERT(!imageLabel->pixmap(Qt::ReturnByValue).isNull()); #if QT_CONFIG(printdialog) //! [6] //! [7] QPrintDialog dialog(&printer, this); //! [7] //! [8] if (dialog.exec()) { QPainter painter(&printer); + QPixmap pixmap = imageLabel->pixmap(Qt::ReturnByValue); QRect rect = painter.viewport(); - QSize size = imageLabel->pixmap()->size(); + QSize size = pixmap.size(); size.scale(rect.size(), Qt::KeepAspectRatio); painter.setViewport(rect.x(), rect.y(), size.width(), size.height()); - painter.setWindow(imageLabel->pixmap()->rect()); - painter.drawPixmap(0, 0, *imageLabel->pixmap()); + painter.setWindow(pixmap.rect()); + painter.drawPixmap(0, 0, pixmap); } #endif } @@ -383,9 +384,8 @@ void ImageViewer::updateActions() void ImageViewer::scaleImage(double factor) //! [23] //! [24] { - Q_ASSERT(imageLabel->pixmap()); scaleFactor *= factor; - imageLabel->resize(scaleFactor * imageLabel->pixmap()->size()); + imageLabel->resize(scaleFactor * imageLabel->pixmap(Qt::ReturnByValue).size()); adjustScrollBar(scrollArea->horizontalScrollBar(), factor); adjustScrollBar(scrollArea->verticalScrollBar(), factor); -- cgit v1.2.3 From c29fac453f3eaac73b29eb0a66d130220d073fc6 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 31 Jan 2020 14:30:20 +0100 Subject: Markdown importer: use Unicode decoding Given we feed UTF-8 data into the importer, it must be able to cope with Unicode. Build md4c with UTF-8 support, advertise it at usage site, and change a couple of broken decodings. Driveby: the textedit example used the wrong codec to decode a Markdown file. While the Markdown spec doesn't deal with encodings, using the default one for HTML is certainly wrong. Port the loading of both markdown and plaintext to UTF-8, as that what _saving_ via QTextDocumentWriter would use by default. Change-Id: I51c6214cfe45ebfc5a67a7366f7866a5328366ec Reviewed-by: Shawn Rutledge --- examples/widgets/richtext/textedit/textedit.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples') diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp index f99fa306df..7708b25a24 100644 --- a/examples/widgets/richtext/textedit/textedit.cpp +++ b/examples/widgets/richtext/textedit/textedit.cpp @@ -419,18 +419,18 @@ bool TextEdit::load(const QString &f) QByteArray data = file.readAll(); QTextCodec *codec = Qt::codecForHtml(data); QString str = codec->toUnicode(data); - QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename); - textEdit->document()->setBaseUrl(baseUrl); if (Qt::mightBeRichText(str)) { + QUrl baseUrl = (f.front() == QLatin1Char(':') ? QUrl(f) : QUrl::fromLocalFile(f)).adjusted(QUrl::RemoveFilename); + textEdit->document()->setBaseUrl(baseUrl); textEdit->setHtml(str); } else { #if QT_CONFIG(textmarkdownreader) QMimeDatabase db; if (db.mimeTypeForFileNameAndData(f, data).name() == QLatin1String("text/markdown")) - textEdit->setMarkdown(str); + textEdit->setMarkdown(QString::fromUtf8(data)); else #endif - textEdit->setPlainText(QString::fromLocal8Bit(data)); + textEdit->setPlainText(QString::fromUtf8(data)); } setCurrentFileName(f); -- cgit v1.2.3 From f415c5ad2392ff79930c6268698703482d6747ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Fri, 7 Feb 2020 11:23:53 +0100 Subject: Remove unused variable Change-Id: I774b1647eff5fcfa0de5bcc50ca2638644b03613 Reviewed-by: Edward Welbourne --- examples/widgets/graphicsview/boxes/scene.h | 1 - 1 file changed, 1 deletion(-) (limited to 'examples') diff --git a/examples/widgets/graphicsview/boxes/scene.h b/examples/widgets/graphicsview/boxes/scene.h index 5d65dc71e2..31bc3d7b66 100644 --- a/examples/widgets/graphicsview/boxes/scene.h +++ b/examples/widgets/graphicsview/boxes/scene.h @@ -215,7 +215,6 @@ private: void initGL(); QPointF pixelPosToViewPos(const QPointF& p); - QTime m_time; // ### Qt 6: remove (unused) int m_lastTime; int m_mouseEventTime; int m_distExp; -- cgit v1.2.3 From c08b0cec2f3acc29e86beba4b1de26caf04bebfd Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Fri, 7 Feb 2020 16:12:27 +0300 Subject: QLocalSocket: Deprecate 'error' signal, use 'errorOccurred' instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][Deprecation Notice] QLocalSocket::error() (the signal) is deprecated; superseded by errorOccurred() Change-Id: I579c07564f5c470cf2867864755e0a26e6afce3b Reviewed-by: Mårten Nordheim --- examples/corelib/ipc/localfortuneclient/client.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/corelib/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp index 8d415f73aa..1ab0c34d6c 100644 --- a/examples/corelib/ipc/localfortuneclient/client.cpp +++ b/examples/corelib/ipc/localfortuneclient/client.cpp @@ -83,8 +83,7 @@ Client::Client(QWidget *parent) this, &Client::requestNewFortune); connect(quitButton, &QPushButton::clicked, this, &Client::close); connect(socket, &QLocalSocket::readyRead, this, &Client::readFortune); - connect(socket, QOverload::of(&QLocalSocket::error), - this, &Client::displayError); + connect(socket, &QLocalSocket::errorOccurred, this, &Client::displayError); QGridLayout *mainLayout = new QGridLayout(this); mainLayout->addWidget(hostLabel, 0, 0); -- cgit v1.2.3 From 5e83a2eed2dc42a732bd9154bebe8dcb34cd6bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 12 Feb 2020 11:14:50 +0100 Subject: Deprecate one overload of QInputDialog::getDouble() for 5.15 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...and merge the two overloads of getDouble() in Qt6 Change-Id: I55faa2ff222b41e48889a0ef14dd00a6da691c36 Reviewed-by: Tor Arne Vestbø --- examples/widgets/dialogs/standarddialogs/dialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/widgets/dialogs/standarddialogs/dialog.cpp b/examples/widgets/dialogs/standarddialogs/dialog.cpp index 77549e60f8..cd7e8085a2 100644 --- a/examples/widgets/dialogs/standarddialogs/dialog.cpp +++ b/examples/widgets/dialogs/standarddialogs/dialog.cpp @@ -329,7 +329,8 @@ void Dialog::setDouble() //! [1] bool ok; double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"), - tr("Amount:"), 37.56, -10000, 10000, 2, &ok); + tr("Amount:"), 37.56, -10000, 10000, 2, &ok, + Qt::WindowFlags(), 1); if (ok) doubleLabel->setText(QString("$%1").arg(d)); //! [1] -- cgit v1.2.3