summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-09-09 16:11:48 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-10-15 20:09:29 +0200
commit9cc040a806fd2e6f1458e801a99311168d594c77 (patch)
tree828ca4008a50f44b7b98f7e50f67d01951b4d9ba /examples
parent92b9dcfe2ba602fc396a4806597b9440ed63bded (diff)
Prepare for deprecating the QDesktopWidget
QDesktopWidget is marked as obsolete in docs, but it is not yet completely deprecated, some of its methods are still in use. Replace uses of the following methods marked as obsolete: - QDesktopWidget::screenNumber(QWidget*) -> QWidget::screen() - QDesktopWidget::screenGeometry(QWidget*) -> QWidget::screen()->geometry() - QDesktopWidget::availableGeometry(QWidget*) -> QWidget::screen()->availableGeometry() Task-number: QTBUG-76491 Change-Id: I2cca30f2b4caa6e6848e8190e09f959d2c272f33 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/main.cpp4
-rw-r--r--examples/network/http/main.cpp4
-rw-r--r--examples/opengl/threadedqopenglwidget/main.cpp4
-rw-r--r--examples/widgets/desktop/screenshot/main.cpp5
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.cpp2
-rw-r--r--examples/widgets/dialogs/standarddialogs/main.cpp4
-rw-r--r--examples/widgets/itemviews/dirview/main.cpp4
-rw-r--r--examples/widgets/mainwindows/application/mainwindow.cpp2
-rw-r--r--examples/widgets/mainwindows/mdi/mainwindow.cpp2
-rw-r--r--examples/widgets/mainwindows/sdi/mainwindow.cpp4
-rw-r--r--examples/widgets/richtext/textedit/main.cpp4
-rw-r--r--examples/widgets/tools/codecs/mainwindow.cpp6
-rw-r--r--examples/widgets/tools/codecs/previewform.cpp4
-rw-r--r--examples/widgets/tools/settingseditor/mainwindow.cpp4
-rw-r--r--examples/widgets/tools/settingseditor/settingstree.cpp4
-rw-r--r--examples/widgets/widgets/charactermap/mainwindow.cpp3
-rw-r--r--examples/widgets/widgets/icons/main.cpp4
-rw-r--r--examples/xml/dombookmarks/mainwindow.cpp2
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp2
-rw-r--r--examples/xml/streambookmarks/mainwindow.cpp2
20 files changed, 36 insertions, 34 deletions
diff --git a/examples/corelib/mimetypes/mimetypebrowser/main.cpp b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
index cf87004a01..679d97dc7b 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/main.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
@@ -51,7 +51,7 @@
#include "mainwindow.h"
#include <QApplication>
-#include <QDesktopWidget>
+#include <QScreen>
#include <QCommandLineParser>
#include <QCommandLineOption>
@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
parser.process(app);
MainWindow mainWindow;
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWindow);
+ const QRect availableGeometry = mainWindow.screen()->availableGeometry();
mainWindow.resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
mainWindow.show();
diff --git a/examples/network/http/main.cpp b/examples/network/http/main.cpp
index b7d254ff22..f126c7846a 100644
--- a/examples/network/http/main.cpp
+++ b/examples/network/http/main.cpp
@@ -49,8 +49,8 @@
****************************************************************************/
#include <QApplication>
-#include <QDesktopWidget>
#include <QDir>
+#include <QScreen>
#include "httpwindow.h"
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
HttpWindow httpWin;
- const QRect availableSize = QApplication::desktop()->availableGeometry(&httpWin);
+ const QRect availableSize = httpWin.screen()->availableGeometry();
httpWin.resize(availableSize.width() / 5, availableSize.height() / 5);
httpWin.move((availableSize.width() - httpWin.width()) / 2, (availableSize.height() - httpWin.height()) / 2);
diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp
index 983f608543..975def030b 100644
--- a/examples/opengl/threadedqopenglwidget/main.cpp
+++ b/examples/opengl/threadedqopenglwidget/main.cpp
@@ -50,7 +50,7 @@
#include <QApplication>
#include <QMainWindow>
-#include <QDesktopWidget>
+#include <QScreen>
#include <QSurfaceFormat>
#include <QOpenGLContext>
#include <QCommandLineParser>
@@ -90,7 +90,7 @@ int main( int argc, char ** argv )
// The rendering for the four QOpenGLWidgets happens on four separate threads.
GLWidget topLevelGlWidget;
- QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200);
+ QPoint pos = topLevelGlWidget.screen()->availableGeometry().topLeft() + QPoint(200, 200);
topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level"));
topLevelGlWidget.resize(200, 200);
topLevelGlWidget.move(pos);
diff --git a/examples/widgets/desktop/screenshot/main.cpp b/examples/widgets/desktop/screenshot/main.cpp
index 825c40b236..96b0d57daa 100644
--- a/examples/widgets/desktop/screenshot/main.cpp
+++ b/examples/widgets/desktop/screenshot/main.cpp
@@ -49,7 +49,7 @@
****************************************************************************/
#include <QApplication>
-#include <QDesktopWidget>
+#include <QScreen>
#include "screenshot.h"
@@ -58,7 +58,8 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
Screenshot screenshot;
- screenshot.move(QApplication::desktop()->availableGeometry(&screenshot).topLeft() + QPoint(20, 20));
+ screenshot.move(screenshot.screen()->availableGeometry().topLeft() + QPoint(20, 20));
screenshot.show();
+
return app.exec();
}
diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp
index 715e6c780e..ce5597bbdd 100644
--- a/examples/widgets/desktop/screenshot/screenshot.cpp
+++ b/examples/widgets/desktop/screenshot/screenshot.cpp
@@ -59,7 +59,7 @@ Screenshot::Screenshot()
screenshotLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
screenshotLabel->setAlignment(Qt::AlignCenter);
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
+ const QRect screenGeometry = screen()->geometry();
screenshotLabel->setMinimumSize(screenGeometry.width() / 8, screenGeometry.height() / 8);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
diff --git a/examples/widgets/dialogs/standarddialogs/main.cpp b/examples/widgets/dialogs/standarddialogs/main.cpp
index f7417f0e45..19ed2bf66f 100644
--- a/examples/widgets/dialogs/standarddialogs/main.cpp
+++ b/examples/widgets/dialogs/standarddialogs/main.cpp
@@ -49,8 +49,8 @@
****************************************************************************/
#include <QApplication>
+#include <QScreen>
#include <QStyleHints>
-#include <QDesktopWidget>
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
Dialog dialog;
if (!QGuiApplication::styleHints()->showIsFullScreen() && !QGuiApplication::styleHints()->showIsMaximized()) {
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(&dialog);
+ const QRect availableGeometry = dialog.screen()->availableGeometry();
dialog.resize(availableGeometry.width() / 3, availableGeometry.height() * 2 / 3);
dialog.move((availableGeometry.width() - dialog.width()) / 2,
(availableGeometry.height() - dialog.height()) / 2);
diff --git a/examples/widgets/itemviews/dirview/main.cpp b/examples/widgets/itemviews/dirview/main.cpp
index 9fecffda40..fcdf4c7ba4 100644
--- a/examples/widgets/itemviews/dirview/main.cpp
+++ b/examples/widgets/itemviews/dirview/main.cpp
@@ -49,9 +49,9 @@
****************************************************************************/
#include <QApplication>
-#include <QDesktopWidget>
#include <QFileSystemModel>
#include <QFileIconProvider>
+#include <QScreen>
#include <QTreeView>
#include <QCommandLineParser>
#include <QCommandLineOption>
@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
tree.setAnimated(false);
tree.setIndentation(20);
tree.setSortingEnabled(true);
- const QSize availableSize = QApplication::desktop()->availableGeometry(&tree).size();
+ const QSize availableSize = tree.screen()->availableGeometry().size();
tree.resize(availableSize / 2);
tree.setColumnWidth(0, tree.width() / 3);
diff --git a/examples/widgets/mainwindows/application/mainwindow.cpp b/examples/widgets/mainwindows/application/mainwindow.cpp
index 7886c4afac..d0c009427f 100644
--- a/examples/widgets/mainwindows/application/mainwindow.cpp
+++ b/examples/widgets/mainwindows/application/mainwindow.cpp
@@ -281,7 +281,7 @@ void MainWindow::readSettings()
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
if (geometry.isEmpty()) {
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
+ const QRect availableGeometry = screen()->availableGeometry();
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
move((availableGeometry.width() - width()) / 2,
(availableGeometry.height() - height()) / 2);
diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp
index b952d19e2e..ccfa7435d7 100644
--- a/examples/widgets/mainwindows/mdi/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mdi/mainwindow.cpp
@@ -464,7 +464,7 @@ void MainWindow::readSettings()
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
if (geometry.isEmpty()) {
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
+ const QRect availableGeometry = screen()->availableGeometry();
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
move((availableGeometry.width() - width()) / 2,
(availableGeometry.height() - height()) / 2);
diff --git a/examples/widgets/mainwindows/sdi/mainwindow.cpp b/examples/widgets/mainwindows/sdi/mainwindow.cpp
index a1fb42158e..c3cd131923 100644
--- a/examples/widgets/mainwindows/sdi/mainwindow.cpp
+++ b/examples/widgets/mainwindows/sdi/mainwindow.cpp
@@ -167,7 +167,7 @@ void MainWindow::tile(const QMainWindow *previous)
if (!topFrameWidth)
topFrameWidth = 40;
const QPoint pos = previous->pos() + 2 * QPoint(topFrameWidth, topFrameWidth);
- if (QApplication::desktop()->availableGeometry(this).contains(rect().bottomRight() + pos))
+ if (screen()->availableGeometry().contains(rect().bottomRight() + pos))
move(pos);
}
@@ -290,7 +290,7 @@ void MainWindow::readSettings()
QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName());
const QByteArray geometry = settings.value("geometry", QByteArray()).toByteArray();
if (geometry.isEmpty()) {
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
+ const QRect availableGeometry = screen()->availableGeometry();
resize(availableGeometry.width() / 3, availableGeometry.height() / 2);
move((availableGeometry.width() - width()) / 2,
(availableGeometry.height() - height()) / 2);
diff --git a/examples/widgets/richtext/textedit/main.cpp b/examples/widgets/richtext/textedit/main.cpp
index aef186aa77..256d183811 100644
--- a/examples/widgets/richtext/textedit/main.cpp
+++ b/examples/widgets/richtext/textedit/main.cpp
@@ -51,9 +51,9 @@
#include "textedit.h"
#include <QApplication>
-#include <QDesktopWidget>
#include <QCommandLineParser>
#include <QCommandLineOption>
+#include <QScreen>
int main(int argc, char *argv[])
{
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
TextEdit mw;
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mw);
+ const QRect availableGeometry = mw.screen()->availableGeometry();
mw.resize(availableGeometry.width() / 2, (availableGeometry.height() * 2) / 3);
mw.move((availableGeometry.width() - mw.width()) / 2,
(availableGeometry.height() - mw.height()) / 2);
diff --git a/examples/widgets/tools/codecs/mainwindow.cpp b/examples/widgets/tools/codecs/mainwindow.cpp
index 6b601062b6..dc72fa73b7 100644
--- a/examples/widgets/tools/codecs/mainwindow.cpp
+++ b/examples/widgets/tools/codecs/mainwindow.cpp
@@ -54,12 +54,12 @@
#include <QAction>
#include <QApplication>
-#include <QDesktopWidget>
#include <QFileDialog>
#include <QMenuBar>
#include <QMessageBox>
#include <QPlainTextEdit>
#include <QRegularExpression>
+#include <QScreen>
#include <QTextCodec>
#include <QTextStream>
@@ -78,7 +78,7 @@ MainWindow::MainWindow()
setWindowTitle(tr("Codecs"));
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
+ const QRect screenGeometry = screen()->geometry();
resize(screenGeometry.width() / 2, screenGeometry.height() * 2 / 3);
}
@@ -216,7 +216,7 @@ void MainWindow::encodingDialog()
{
if (!m_encodingDialog) {
m_encodingDialog = new EncodingDialog(this);
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
+ const QRect screenGeometry = screen()->geometry();
m_encodingDialog->setMinimumWidth(screenGeometry.width() / 4);
}
m_encodingDialog->show();
diff --git a/examples/widgets/tools/codecs/previewform.cpp b/examples/widgets/tools/codecs/previewform.cpp
index ec75ebb9fa..f48651335a 100644
--- a/examples/widgets/tools/codecs/previewform.cpp
+++ b/examples/widgets/tools/codecs/previewform.cpp
@@ -52,12 +52,12 @@
#include <QApplication>
#include <QComboBox>
-#include <QDesktopWidget>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>
#include <QPlainTextEdit>
#include <QPushButton>
+#include <QScreen>
#include <QTextCodec>
#include <QTextStream>
@@ -183,7 +183,7 @@ PreviewForm::PreviewForm(QWidget *parent)
mainLayout->addWidget(statusLabel, 2, 0, 1, 2);
mainLayout->addWidget(buttonBox, 3, 0, 1, 2);
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
+ const QRect screenGeometry = screen()->geometry();
resize(screenGeometry.width() * 2 / 5, screenGeometry.height() / 2);
}
diff --git a/examples/widgets/tools/settingseditor/mainwindow.cpp b/examples/widgets/tools/settingseditor/mainwindow.cpp
index b9c2193ccb..ccca16ffcd 100644
--- a/examples/widgets/tools/settingseditor/mainwindow.cpp
+++ b/examples/widgets/tools/settingseditor/mainwindow.cpp
@@ -54,12 +54,12 @@
#include <QAction>
#include <QApplication>
-#include <QDesktopWidget>
#include <QFileDialog>
#include <QInputDialog>
#include <QLineEdit>
#include <QMenuBar>
#include <QMessageBox>
+#include <QScreen>
#include <QStandardPaths>
#include <QStatusBar>
@@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
fallbacksAct->setChecked(true);
setWindowTitle(QCoreApplication::applicationName());
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
+ const QRect availableGeometry = screen()->availableGeometry();
adjustSize();
move((availableGeometry.width() - width()) / 2, (availableGeometry.height() - height()) / 2);
}
diff --git a/examples/widgets/tools/settingseditor/settingstree.cpp b/examples/widgets/tools/settingseditor/settingstree.cpp
index b263746847..49d299bf72 100644
--- a/examples/widgets/tools/settingseditor/settingstree.cpp
+++ b/examples/widgets/tools/settingseditor/settingstree.cpp
@@ -52,8 +52,8 @@
#include "variantdelegate.h"
#include <QApplication>
-#include <QDesktopWidget>
#include <QHeaderView>
+#include <QScreen>
#include <QSettings>
SettingsTree::SettingsTree(QWidget *parent)
@@ -93,7 +93,7 @@ void SettingsTree::setSettingsObject(const SettingsPtr &newSettings)
QSize SettingsTree::sizeHint() const
{
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
+ const QRect availableGeometry = screen()->availableGeometry();
return QSize(availableGeometry.width() * 2 / 3, availableGeometry.height() * 2 / 3);
}
diff --git a/examples/widgets/widgets/charactermap/mainwindow.cpp b/examples/widgets/widgets/charactermap/mainwindow.cpp
index 25c4503ddb..b0f9705c21 100644
--- a/examples/widgets/widgets/charactermap/mainwindow.cpp
+++ b/examples/widgets/widgets/charactermap/mainwindow.cpp
@@ -64,6 +64,7 @@
#include <QMenuBar>
#include <QPlainTextEdit>
#include <QPushButton>
+#include <QScreen>
#include <QScrollArea>
#include <QStatusBar>
#include <QTextStream>
@@ -302,7 +303,7 @@ QString FontInfoDialog::text() const
void MainWindow::showInfo()
{
- const QRect screenGeometry = QApplication::desktop()->screenGeometry(this);
+ const QRect screenGeometry = screen()->geometry();
FontInfoDialog *dialog = new FontInfoDialog(this);
dialog->setWindowTitle(tr("Fonts"));
dialog->setAttribute(Qt::WA_DeleteOnClose);
diff --git a/examples/widgets/widgets/icons/main.cpp b/examples/widgets/widgets/icons/main.cpp
index a045ea765a..632795c18c 100644
--- a/examples/widgets/widgets/icons/main.cpp
+++ b/examples/widgets/widgets/icons/main.cpp
@@ -50,7 +50,7 @@
#include <QApplication>
#include <QCommandLineParser>
-#include <QDesktopWidget>
+#include <QScreen>
#include "mainwindow.h"
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
if (!commandLineParser.positionalArguments().isEmpty())
mainWin.loadImages(commandLineParser.positionalArguments());
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(&mainWin);
+ const QRect availableGeometry = mainWin.screen()->availableGeometry();
mainWin.resize(availableGeometry.width() / 2, availableGeometry.height() * 2 / 3);
mainWin.move((availableGeometry.width() - mainWin.width()) / 2, (availableGeometry.height() - mainWin.height()) / 2);
diff --git a/examples/xml/dombookmarks/mainwindow.cpp b/examples/xml/dombookmarks/mainwindow.cpp
index fade2dfc96..b8f2e12918 100644
--- a/examples/xml/dombookmarks/mainwindow.cpp
+++ b/examples/xml/dombookmarks/mainwindow.cpp
@@ -63,7 +63,7 @@ MainWindow::MainWindow()
statusBar()->showMessage(tr("Ready"));
setWindowTitle(tr("DOM Bookmarks"));
- const QSize availableSize = QApplication::desktop()->availableGeometry(this).size();
+ const QSize availableSize = screen()->availableGeometry().size();
resize(availableSize.width() / 2, availableSize.height() / 3);
}
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
index 0583cd82cf..8b7733081f 100644
--- a/examples/xml/saxbookmarks/mainwindow.cpp
+++ b/examples/xml/saxbookmarks/mainwindow.cpp
@@ -74,7 +74,7 @@ MainWindow::MainWindow()
statusBar()->showMessage(tr("Ready"));
setWindowTitle(tr("SAX Bookmarks"));
- const QSize availableSize = QApplication::desktop()->availableGeometry(this).size();
+ const QSize availableSize = screen()->availableGeometry().size();
resize(availableSize.width() / 2, availableSize.height() / 3);
}
diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp
index c9a18fa3c4..d0e7bf30c9 100644
--- a/examples/xml/streambookmarks/mainwindow.cpp
+++ b/examples/xml/streambookmarks/mainwindow.cpp
@@ -75,7 +75,7 @@ MainWindow::MainWindow()
statusBar()->showMessage(tr("Ready"));
setWindowTitle(tr("QXmlStream Bookmarks"));
- const QSize availableSize = QApplication::desktop()->availableGeometry(this).size();
+ const QSize availableSize = screen()->availableGeometry().size();
resize(availableSize.width() / 2, availableSize.height() / 3);
}
//! [0]