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

Mac: QPushButton fixed size used is not respected

XMLWordPrintable

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

      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;
      

        1. patch.diff
          2 kB
        2. main2.cpp
          0.5 kB
        3. main.zip
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes