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

QGraphicsGridLayout column spacing affects size even after item removal

    XMLWordPrintable

Details

    • 183abff6ffcb020b8f0c4041cc82bba0d3b03863

    Description

      In QGraphicsGridLayout, column spacing affects layout size even if the items are removed and columnCount returns zero. Internally the column count (QGridLayoutEngine::columnCount()) is still the same as before removing.

      Attached test case (modified tst_qgraphicsgridlayout):

      void SpacingTest::columnSpacing()
      {
          QGraphicsScene scene;
          QGraphicsView view(&scene);
          QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window);
          QGraphicsGridLayout *layout = new QGraphicsGridLayout();
          scene.addItem(widget);
          widget->setLayout(layout);
          populateLayout(layout, 2, 1);
          layout->setContentsMargins(0, 0, 0, 0);
          layout->setColumnSpacing(0, 20);
          view.show();
          widget->show();
          layout->removeAt(1);
          layout->removeAt(0);
          widget->resize(widget->effectiveSizeHint(Qt::MinimumSize));
          QApplication::processEvents();
      
          QCOMPARE(layout->preferredSize(), QSizeF(0, 0)); // is (20,0)
      
          delete widget;
      }
      

      Attachments

        1. spacingtest.pro
          0.1 kB
        2. tst_spacing.cpp
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            smd Jan Arve
            kko Kimmo Kotajärvi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes