Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62094

Investigate usefulness of QDesktopWidget::screenNumber API and the QDesktopWidget in general.

    XMLWordPrintable

Details

    • Task
    • Resolution: Done
    • P2: Important
    • 6.0
    • None
    • Other
    • None

    Description

      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:

      QPoint pos;
      int screenNr = QApplication::desktop()->screenNumber(p);
      QRect geo = QApplication::desktop()->screenGeometry(screenNr);
      

      when a cleaner way exist (I have seen the above pattern in many places):

      QPoint pos;
      QRect geo = QApplication::desktop()->screenGeometry(pos);
      

      Why have:

      QDesktopWidget::availableGeometry
      QDesktopWidget::screenGeometry
      

      When we can add methods returning QScreen:

      QScreen * QDesktopWidget::screen(const QPoint &p) const
      QScreen * QDesktopWidget::screen(const QWidget *widget) const
      

      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.

      Attachments

        Issue Links

          There are no Sub-Tasks for this issue.
          For Gerrit Dashboard: QTBUG-62094
          # Subject Branch Project Status CR V

          Activity

            People

              vhilshei Volker Hilsheimer
              paeglis Gatis Paeglis
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: