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

QDateTimeEdit with calendarPopup set to true has visual issues on Mac

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.2.1
    • None
    • Qt 5.2.1 on a Mac running OSX 10.8
    • macOS

    Description

      QDateTimeEdit with calendarPopup set to true has rendering issues on the Mac.

      Reproduction Steps:

      1. Create a new Qt Designer app project in Qt Creator on the Mac.
      2. Add a QDateTimeEdit control to the main window.
      3. Check the box next to "calendarPopup"

      Expected:
      QDateTimeEdit renders similar to what it did in Qt 4.8.4

      Actual:
      The edit field is shifted.

      Attached is a screen shot of the sample application in Qt Creator and running.

      Some investigation in to the QT code revealed a change in QMacStylePrivate::comboboxEditBounds that accounts for some of the shift.

      QMacStyle::subControlRect contains specific code to adjust the the rect for combo boxes when being used with QDateTimeEdit but this code did not change for Qt 5.2.1.

      The Workaround

      Create a QT Style for your application with the following overlaoded code

      QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex * option, QStyle::SubControl subControl, const QWidget * widget) const
      {
          switch(control)
          {
          case CC_ComboBox:
              {
                  if(subControl == SC_ComboBoxEditField)
                  {
                      if(qobject_cast<const QDateTimeEdit*>(widget))
                      {
                          QRect result = TableauMacProxyStyle::subControlRect(control, option, subControl, widget);
      
      
                          result.moveTop(result.top() + 3);
                          result.setHeight(result.height() - 3);
                          result.setWidth(result.width() - 2);
                          return result;
                      }
                  }
              }
              break;
          }
          return BASE_CLASS::subControlRect(control, option, subControl, widget);
      }
      

      Attachments

        1. QDateTimeEdit in Qt Creator.png
          254 kB
          Nicolas Teeuwen
        2. QDateTimeEdit broken rendering.png
          13 kB
          Nicolas Teeuwen
        3. Code Diff between 4.8.4 and 5.2.1.png
          48 kB
          Nicolas Teeuwen

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              nteeuwentableau Nicolas Teeuwen
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes