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

Handling spacer without sizeHint property generates incorrect code

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6
    • 5.3.2, 5.6.1
    • Build tools: uic
    • None
    • 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

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

        Activity

          People

            jkobus Jarek Kobus
            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