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

Handling spacer without sizeHint property generates incorrect code

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.3.2, 5.6.1
    • Fix Version/s: 5.6
    • Component/s: Build tools: uic
    • Labels:
      None
    • Commits:
      385ab06fb1d99322872dc84f0e077886a917b9a7

      Description

      To reproduce, in Designer mode of QtCreator:
      1. Add Spacer (Vertical or Horizontal) onto some widget with layout.
      2. Reset sizeHint to default in properties panel

      It will generate code like this:

          <item>
           <spacer name="horizontalSpacer">
            <property name="orientation">
             <enum>Qt::Horizontal</enum>
            </property>
           </spacer>
          </item>
      

      Compiling this code with uic will generate compilable, but incorrect C++ code, which will lead to incorrect Spacer behavior:

      horizontalSpacer = new QSpacerItem(QSizePolicy::Expanding, QSizePolicy::Minimum);
      

      QSpacerItem constructor signature is:

      QSpacerItem(int w, int h,
                       QSizePolicy::Policy hData = QSizePolicy::Minimum,
                       QSizePolicy::Policy vData = QSizePolicy::Minimum);
      

      So, in generated C++ code two actual QSizePolicy arguments will be implicitly cast to int, and used as width and height, while formal hData and wData will silently get default values. It's incorrect of course.

        Attachments

        For Gerrit Dashboard: QTBUG-55008
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            jkobus Jarek Kobus
            Reporter:
            lilovip Ilia Lilov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes