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

QScrollArea: The viewport bleeds through another widget when the scroll bar is reset.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 6.2.3, 6.3.0 Alpha
    • 4.7.4, 4.8.2, 5.4.0 Beta, 5.5.1, 5.9.1, 6.2
    • None
    • Windows 7, x64 (Intel i5), VS2008
      Ubuntu 12.04 64-bit
    • 22634e00794e72d68e7578e1962f9f2023870749 (qt/qtbase/dev) 94c2953aa9e1616e13d45ad60d37a793651491d4 (qt/qtbase/6.2)

    Description

      QScrollArea: The viewport bleeds through another widget when the scroll bar is reset.
      (see the second screenshot).

      Bar.java
      #include <QApplication>
      #include <QScrollArea>
      #include <QPainter>
      #include <QPaintEvent>
      #include <QScrollBar>
      
      class CustomWidget : public QWidget
      {
      public:
          CustomWidget(const QColor &b, QWidget *parent = 0)
              : QWidget(parent), background(b)
          {
          }
          
          void paintEvent(QPaintEvent *e)
          {
              QPainter p(this);
              p.fillRect(e->rect(), background);
          }
      
          QColor background;
      };
      
      class MainWidget : public QWidget
      {
      public:
          MainWidget(QWidget *parent = 0)
          : QWidget(parent)
          {
              area = new QScrollArea(this);
              area->setWidget(new CustomWidget(Qt::gray));
      
              widget = new CustomWidget(Qt::red, this);
      
              timerId = startTimer(100);
          }
      
          void resizeEvent(QResizeEvent *e)
          {
              QWidget::resizeEvent(e);
      
              area->resize(800, 100);
              area->widget()->resize(5000, 600);
              area->move((width() - area->width()) / 2, (height() - area->height()) / 2);
      
              widget->resize(500, 200);
              widget->move((width() - widget->width()) / 2, (height() - widget->height()) / 2);
          }
      
          void timerEvent(QTimerEvent *e)
          {
              if (e->timerId() == timerId) {
                  if (area->horizontalScrollBar()->value() == area->horizontalScrollBar()->maximum())
                      area->horizontalScrollBar()->setValue(0);
                  else
                      area->horizontalScrollBar()->setValue(area->horizontalScrollBar()->value() + 200);
              } else {
                  QWidget::timerEvent(e);
              }
          }
      
      private:
          QScrollArea *area;
          CustomWidget *widget;
          int timerId;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          MainWidget w;
          w.showMaximized();
          return app.exec();
      }
      

      Attachments

        1. QTBUG-26269.patch
          2 kB
        2. qtbug26269.zip
          2 kB
        3. screen_shot_1.png
          screen_shot_1.png
          12 kB
        4. screen_shot_2.png
          screen_shot_2.png
          11 kB
        5. ScrollViewTest.zip
          1 kB
        6. ScrollViewTest.zip
          1.0 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            tiamatenko Korobov Sergiy
            Votes:
            13 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: