I wonder on which platform screen number maps to something useful?
Seems like unnecessary burden to maintain and allows people to write non-optimal code, e.g:
when a cleaner way exist (I have seen the above pattern in many places):
When we can add methods returning QScreen:
enabling developers to call ::availableGeometry() / ::screenGeometry() directly on QScreen? This gives access to more meaningful screen identifiers (compared to arbitrary screen numbers) - QScreen::model(), QScreen::name().
With these changes QDesktopWidget API would become very minimalistic (without loosing any of existing functionality), thus it might make sense to deprecate the whole class and move this tiny API over to QGuiApplication, which already has QScreen related methods, such as - ::primaryScreen(), ::screenAdded(), ::screenRemoved(), ::screens().
Furthermore, QDesktopWidget is a QWidget sub-class, so having this API in QGuiApplication would make it accessible to QML without widget dependency.
Bonus is that we could cleanup our code in various places from checks like ( .. != Qt::Desktop ), as it was necessary for QDesktopWidget purposes-only AFAICT.
|For Gerrit Dashboard: QTBUG-62094|
|205020,19||Deprecate QDesktopWidget in favor of QScreen||dev||qt/qtbase||Status: MERGED||+2||0|
|249238,2||QSplashScreen: Fix positioning in multimonitor setups||5.12||qt/qtbase||Status: MERGED||+2||0|
|252033,3||Replace deprecated QDesktopWidget::screenGeometry usage in simplebrowser||5.13||qt/qtwebengine||Status: MERGED||+2||0|
|258304,8||Add accessors for QWindow and QScreen to QWidgetPrivate||dev||qt/qtbase||Status: MERGED||+2||0|
|258305,13||Add screen() accessor to QWidget||5.14||qt/qtbase||Status: MERGED||+2||0|
|266892,4||QtWidgets: Fix wrong screen returned by newly added QWidgetPrivate::associatedScreen()||dev||qt/qtbase||Status: MERGED||+2||0|