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

Layout change in a QScrollArea causes a brief visual jump

    XMLWordPrintable

Details

    Description

      Adding a Widget to the layout of a QScrollArea causes the view to flicker. It seems that the widgets are resized at the reception of the resize event from the scroll area. This problem is especially visible with smalls CPU.

      The following code demonstrate the problem:

      class ScrollJump : public QWidget
      {
      Q_OBJECT

      public:
      ScrollJump(QWidget *parent = 0, Qt::WFlags flags = 0):QWidget(parent, flags)

      { QVBoxLayout *verticalLayout = new QVBoxLayout(this); QPushButton *pushButton = new QPushButton("Push me a few times"); connect(pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked())); verticalLayout->addWidget(pushButton); QScrollArea *scrollArea = new QScrollArea(); scrollArea->setWidgetResizable(true); QWidget *viewport = new QWidget(); m_viewportLayout = new QVBoxLayout(viewport); scrollArea->setWidget(viewport); verticalLayout->addWidget(scrollArea); m_viewportLayout->addStretch(); }

      private:
      QVBoxLayout* m_viewportLayout;

      private slots:
      void on_pushButton_clicked()

      { static int i = 1; m_viewportLayout->insertWidget(m_viewportLayout->count() - 1, new QLabel(QString::number(i++))); }

      };

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      ScrollJump w;
      w.show();
      return a.exec();
      }

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            poulain Benjamin Poulain (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes