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

Mac: QPushButton fixed size used is not respected

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 4.7.1
    • None
    • macOS

    Description

      The size of a QPushButton is wrong when a fixed size is applied with the width of the button is > 50 and the height is > 30.

      Included a test case to reproduce

      Suggested workaround/patch

      diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
      index 128d6bf..c067a64 100644
      --- a/src/gui/styles/qmacstyle_mac.mm
      +++ b/src/gui/styles/qmacstyle_mac.mm
      @@ -3398,10 +3404,17 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
                   // the focus 'shadow' will be inside.
                   HIRect newRect = qt_hirectForQRect(btn->rect);
                   if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) {
      -                newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset;
      -                newRect.origin.y += QMacStylePrivate::PushButtonTopOffset;
      -                newRect.size.width -= QMacStylePrivate::PushButtonRightOffset;
      -                newRect.size.height -= QMacStylePrivate::PushButtonBottomOffset;
      +                if (w->minimumWidth() != w->maximumWidth())
      +                {
      +                    newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset;
      +                    newRect.size.width -= QMacStylePrivate::PushButtonRightOffset;
      +                }
      +                if (w->minimumHeight() != w->maximumHeight())
      +                {
      +                    newRect.origin.y += QMacStylePrivate::PushButtonTopOffset;
      +                    newRect.size.height -= QMacStylePrivate::PushButtonBottomOffset;
      +                }
                   } else if (bdi.kind == kThemePushButtonMini) {
                       newRect.origin.x += QMacStylePrivate::PushButtonLeftOffset - 2;
                       newRect.origin.y += QMacStylePrivate::PushButtonTopOffset;
      

      Attachments

        1. patch.diff
          2 kB
        2. main2.cpp
          0.5 kB
        3. main.zip
          1 kB

        Issue Links

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

          Activity

            People

              tpochep Timur Pocheptsov
              sanonymous Nokia Qt Support (Inactive)
              Votes:
              13 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes