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

QSpinBox still reserves space for buttons even when told to not show any buttons via QAbstractSpinBox::NoButtons (revival of QTBUG-1395)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.13.1, 5.14.0 Alpha
    • 5.2.0
    • GUI: Painting
    • None
    • Windows 7, OSX 10.9.2
    • aa8d3f90a440575deef914916299b792105d7209 (qt/qtbase/5.13)

    Description

      NOTE: This bug is being reported against Qt release 5.2.1, although for some reason that release now appears to be missing from the "Affects Version/s" field, so I was forced to pick the nearest match, which is "5.2.0".

      QTBUG-1395 still repros in 5.2.1, and it's impacting our product. I don't see any way to reactivate QTBUG-1395, so I'm creating this bug instead.

      I have crafted a fix which appears to resolve this issue on both Windows and Mac on our end.

      Perforce diff of the proposed fix:

      ==== //depot/third-party/qt/5.2/local/qtbase/src/widgets/styles/qcommonstyle.cpp#1 (text) ====

      @@ -4820,7 +4820,7 @@
      case CT_SpinBox:
      if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt))

      { // Add button + frame widths - int buttonWidth = 20; + int buttonWidth = subControlRect(CC_SpinBox, vopt, SC_SpinBoxUp, widget).width(); int fw = vopt->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget) : 0; sz += QSize(buttonWidth + 2*fw, 2*fw); }

      ==== //depot/third-party/qt/5.2/local/qtbase/src/widgets/styles/qmacstyle_mac.mm#3 (text) ====

      @@ -6085,7 +6085,7 @@
      case CT_SpinBox:
      if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt))

      { // Add button + frame widths - int buttonWidth = 20; + int buttonWidth = subControlRect(CC_SpinBox, vopt, SC_SpinBoxUp, widget).width(); int fw = proxy()->pixelMetric(PM_SpinBoxFrameWidth, vopt, widget); sz += QSize(buttonWidth + 2*fw, 2*fw - 3); }

      ==== //depot/third-party/qt/5.2/local/qtbase/src/widgets/styles/qstylesheetstyle.cpp#2 (text) ====

      @@ -4811,15 +4811,18 @@
      switch (ct) {
      case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1)
      if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {

      • // Add some space for the up/down buttons
      • QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
      • if (subRule.hasDrawable()) { - QRect r = positionRect(w, rule, subRule, PseudoElement_SpinBoxUpButton, - opt->rect, opt->direction); - sz += QSize(r.width(), 0); - }

        else {

      • QSize defaultUpSize = defaultSize(w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton);
      • sz += QSize(defaultUpSize.width(), 0);
        + if (spinbox->buttonSymbols != QAbstractSpinBox::NoButtons)
        +
        Unknown macro: {+ // Add some space for the up/down buttons+ QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);+ if (subRule.hasDrawable()) { + QRect r = positionRect(w, rule, subRule, PseudoElement_SpinBoxUpButton, + opt->rect, opt->direction); + sz += QSize(r.width(), 0); + } else { + QSize defaultUpSize = defaultSize(w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton); + sz += QSize(defaultUpSize.width(), 0); + } }

        if (rule.hasBox() || rule.hasBorder() || !rule.hasNativeBorder())
        sz = rule.boxSize(sz);

      Attachments

        Issue Links

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

          Activity

            People

              chehrlic Christian Ehrlicher
              kkelly@tableausoftware.com Keith F. Kelly
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes