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

QDesktopWidget::availableGeometry() returns wrong value s under MacOS/X

    XMLWordPrintable

Details

    • macOS
    • d895d7cc8908ce5c6157c8261b9145d81b21501f, e219feca14eb96a39d38694edfcc810ed94539ff

    Description

      Platform:

      Mac OS X

      Platform details:

      Apple iMac
      2.16 GHz Intel Core 2 Duo
      2GB RAM

      OS/X 10.6.1

      Compilers:

      GCC

      Compiler details:
      i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646)

      Steps to reproduce / test case:

      1) Compile and run the attached code
      2) Note that the displayed window says "availableGeometry: left=0 top=0 width=1920 height=1100"
      3) That is incorrect – it doesn't take into account area at the top of the screen where the mac's system-wide menu bar is. Expected behavior would be for it to say something like "availableGeometry: left=0 top=20 width=1920 height=1080"

      This problem was reproduced in both the Cocoa and Carbon builds of Qt 4.6.1-beta for MacOS/X.

      More information:

      #include <stdio.h> 
      #include <QApplication> 
      #include <QDesktopWidget> 
      #include <QLabel> 
      
      class MyLabel : public QLabel 
      { 
      public: 
      MyLabel() 
      { 
      setMinimumSize(500,100); 
      setAlignment(Qt::AlignCenter); 
      } 
      
      virtual void showEvent(QShowEvent * e) 
      { 
      QLabel::showEvent(e); 
      QRect ag = qApp->desktop()->availableGeometry(); 
      char buf[512]; 
      sprintf(buf, "availableGeometry: left=%i top=%i width=%i height=%i\n", ag.left(), ag.top(), ag.width(), ag.height()); 
      setText(buf); 
      } 
      }; 
      
      int main(int argc, char ** argv) 
      { 
      QApplication app(argc, argv); 
      
      MyLabel lab; 
      lab.show(); 
      return app.exec(); 
      } 
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            sthomass Stian Sandvik Thomassen (closed Nokia identity) (Inactive)
            Votes:
            6 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes