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

QGraphicsLinearLayout - strange behaviour with trying to center a widget

    XMLWordPrintable

Details

    Description

      I create a horizontal linear layout and add three widgets:

      1) QGraphicsWidget with preferredsize 0,0 and sizepolicy QSizePolicy::Preferred,QSizePolicy::Preferred
      2) QGraphicsWidget with min and max size of 80,80 and sizepolicy QSizePolicy::Preferred,QSizePolicy::Preferred
      3) QGraphicsWidget with preferredsize 0,0 and sizepolicy QSizePolicy::Preferred,QSizePolicy::Preferred

      I would expect that the middle widget is centered. However the items 1 and 3 get a size of 0, even if there if room for them to grow. Changing the preferredSize to 1,1 helps in this case, but now consider:

      1) QGraphicsWidget with preferredsize 0,0 or 1,1 and sizepolicy QSizePolicy::Preferred,QSizePolicy::Preferred
      2) QGraphicsWidget with min and max size of 80,80 and sizepolicy QSizePolicy::Expanding,QSizePolicy::Expanding
      3) QGraphicsWidget with preferredsize 0,0 or 1,1 and sizepolicy QSizePolicy::Preferred,QSizePolicy::Preferred

      Again I would expect that the middle widget is centered, but it is left aligned with the first and large widget getting a size of 1 only.

      Printing out the layout->geometry() in both cases gives a geometry width of 300.

      (Test case included, tested with Qt 4.6.3)

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            johnflux John Tapsell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes