QtBase  v6.3.1
tst_qwidgetrepaintmanager.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2021 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 
30 #include <QTest>
31 #include <QPainter>
32 #include <QScrollArea>
33 #include <QScrollBar>
34 #include <QApplication>
35 
36 #include <private/qhighdpiscaling_p.h>
37 #include <private/qwidget_p.h>
38 #include <private/qwidgetrepaintmanager_p.h>
39 #include <qpa/qplatformbackingstore.h>
40 
41 //#define MANUAL_DEBUG
42 
43 class TestWidget : public QWidget
44 {
45 public:
47  : QWidget(parent)
48  {
49  }
50 
51  QSize sizeHint() const override
52  {
53  const int screenWidth = QGuiApplication::primaryScreen()->geometry().width();
54  const int width = qMax(200, 100 * ((screenWidth + 500) / 1000));
55  return isWindow() ? QSize(width, width) : QSize(width - 40, width - 40);
56  }
57 
58  void initialShow()
59  {
60  show();
61  if (isWindow())
63  paintedRegions = {};
64  }
65 
66  bool waitForPainted(int timeout = 5000)
67  {
68  return QTest::qWaitFor([this]{ return !paintedRegions.isEmpty(); }, timeout);
69  }
70 
72  {
74  paintedRegions = {};
75  return result;
76  }
78 
79 protected:
80  void paintEvent(QPaintEvent *event) override
81  {
82  paintedRegions += event->region();
83  QPainter painter(this);
84  const QBrush patternBrush = isWindow() ? QBrush(Qt::blue, Qt::VerPattern)
86  painter.fillRect(rect(), patternBrush);
87  }
88 };
89 
90 class OpaqueWidget : public QWidget
91 {
92 public:
93  OpaqueWidget(const QColor &col, QWidget *parent = nullptr)
94  : QWidget(parent), fillColor(col)
95  {
97  }
98 
99 protected:
100  void paintEvent(QPaintEvent *e) override
101  {
102  Q_UNUSED(e);
103  QPainter painter(this);
104  fillColor.setBlue(paintCount % 255);
105  painter.fillRect(e->rect(), fillColor);
106 #ifdef MANUAL_DEBUG
107  ++paintCount;
109 #endif
110  }
111 
112 private:
113  QColor fillColor;
114  int paintCount = 0;
115 };
116 
117 class Draggable : public OpaqueWidget
118 {
119 public:
122  {
123  }
124 
125  Draggable(const QColor &col, QWidget *parent = nullptr)
126  : OpaqueWidget(col, parent)
127  {
128  left = new OpaqueWidget(Qt::gray, this);
129  top = new OpaqueWidget(Qt::gray, this);
130  right = new OpaqueWidget(Qt::gray, this);
131  bottom = new OpaqueWidget(Qt::gray, this);
132  }
133 
134  QSize sizeHint() const override {
135  return QSize(100, 100);
136  }
137 
138 protected:
139  void resizeEvent(QResizeEvent *) override
140  {
141  if (!left)
142  return;
143  left->setGeometry(0, 0, 10, height());
144  top->setGeometry(10, 0, width() - 10, 10);
145  right->setGeometry(width() - 10, 10, 10, height() - 10);
146  bottom->setGeometry(10, height() - 10, width() - 10, 10);
147  }
148 
149  void mousePressEvent(QMouseEvent *e) override
150  {
151  lastPos = e->position().toPoint();
152  }
153  void mouseMoveEvent(QMouseEvent *e) override
154  {
155  QPoint pos = geometry().topLeft();
156  pos += e->position().toPoint() - lastPos;
157  move(pos);
158  }
160  {
161  lastPos = {};
162  }
163 
164 private:
165  OpaqueWidget *left = nullptr;
166  OpaqueWidget *top = nullptr;
167  OpaqueWidget *right = nullptr;
168  OpaqueWidget *bottom = nullptr;
169  QPoint lastPos;
170 };
171 
172 class TestScene : public QWidget
173 {
174 public:
176  {
177  setObjectName("scene");
178 
179  // opaque because it has an opaque background color and autoFillBackground is set
180  area = new QWidget(this);
181  area->setObjectName("area");
186 
187  // all these children set WA_OpaquePaintEvent
188  redChild = new Draggable(Qt::red, area);
189  redChild->setObjectName("redChild");
190 
192  greenChild->setObjectName("greenChild");
193 
194  yellowChild = new Draggable(Qt::yellow, this);
195  yellowChild->setObjectName("yellowChild");
196 
197  nakedChild = new Draggable(this);
198  nakedChild->move(300, 0);
199  nakedChild->setObjectName("nakedChild");
200 
201  bar = new OpaqueWidget(Qt::darkGray, this);
202  bar->setObjectName("bar");
203  }
204 
211 
212  QSize sizeHint() const override { return QSize(400, 400); }
213 
214 protected:
215  void resizeEvent(QResizeEvent *) override
216  {
217  area->setGeometry(50, 50, width() - 100, height() - 100);
218  bar->setGeometry(width() / 2 - 25, height() / 2, 50, height() / 2);
219  }
220 };
221 
223 {
224  Q_OBJECT
225 
226 public:
228 
229 public slots:
230  void initTestCase();
231  void cleanup();
232 
233 private slots:
234  void basic();
235  void children();
236  void opaqueChildren();
237  void staticContents();
238  void scroll();
239 #if defined(QT_BUILD_INTERNAL)
240  void scrollWithOverlap();
241  void overlappedRegion();
242  void fastMove();
243  void moveAccross();
244  void moveInOutOverlapped();
245 
246 protected:
247  /*
248  This helper compares the widget as rendered into the backingstore with the widget
249  as rendered via QWidget::grab. The latter always produces a fully rendered image,
250  so differences indicate bugs in QWidgetRepaintManager's or QWidget's painting code.
251  */
252  bool compareWidget(QWidget *w)
253  {
254  if (!waitForFlush(w)) {
255  qWarning() << "Widget" << w << "failed to flush";
256  return false;
257  }
258  QBackingStore *backingStore = w->window()->backingStore();
259  Q_ASSERT(backingStore && backingStore->handle());
260  QPlatformBackingStore *platformBackingStore = backingStore->handle();
261 
262  QImage backingstoreContent = platformBackingStore->toImage();
263  if (!w->isWindow()) {
264  const qreal dpr = w->devicePixelRatioF();
265  const QPointF offset = w->mapTo(w->window(), QPointF(0, 0)) * dpr;
266  backingstoreContent = backingstoreContent.copy(offset.x(), offset.y(), w->width() * dpr, w->height() * dpr);
267  }
268  const QImage widgetRender = w->grab().toImage().convertToFormat(backingstoreContent.format());
269 
270  const bool result = backingstoreContent == widgetRender;
271 
272 #ifdef MANUAL_DEBUG
273  if (!result) {
274  backingstoreContent.save(QString("/tmp/backingstore_%1_%2.png").arg(QTest::currentTestFunction(), QTest::currentDataTag()));
275  widgetRender.save(QString("/tmp/grab_%1_%2.png").arg(QTest::currentTestFunction(), QTest::currentDataTag()));
276  }
277 #endif
278  return result;
279  };
280 
281  QRegion dirtyRegion(QWidget *widget) const
282  {
284  }
285  bool waitForFlush(QWidget *widget) const
286  {
288  return QTest::qWaitFor([repaintManager]{ return !repaintManager->isDirty(); } );
289  };
290 #endif // QT_BUILD_INTERNAL
291 
292 
293 private:
294  const int m_fuzz;
295  bool m_implementsScroll = false;
296 };
297 
299  m_fuzz(int(QHighDpiScaling::factor(QGuiApplication::primaryScreen())))
300 {
301 }
302 
304 {
305  QWidget widget;
306  widget.show();
308 
309  m_implementsScroll = widget.backingStore()->handle()->scroll(QRegion(widget.rect()), 1, 1);
310  qDebug() << QGuiApplication::platformName() << "QPA backend implements scroll:" << m_implementsScroll;
311 }
312 
314 {
316 }
317 
318 void tst_QWidgetRepaintManager::basic()
319 {
321  widget.show();
323 
324  QCOMPARE(widget.takePaintedRegions(), QRegion(0, 0, widget.width(), widget.height()));
325 
326  widget.update();
327  QVERIFY(widget.waitForPainted());
328  QCOMPARE(widget.takePaintedRegions(), QRegion(0, 0, widget.width(), widget.height()));
329 
330  widget.repaint();
331  QCOMPARE(widget.takePaintedRegions(), QRegion(0, 0, widget.width(), widget.height()));
332 }
333 
338 void tst_QWidgetRepaintManager::children()
339 {
340  if (QStringList{"android"}.contains(QGuiApplication::platformName()))
341  QSKIP("This test fails on Android");
342 
344  widget.initialShow();
345 
346  TestWidget *child1 = new TestWidget(&widget);
347  child1->move(20, 20);
348  child1->show();
349  QVERIFY(child1->waitForPainted());
350  QCOMPARE(widget.takePaintedRegions(), QRegion(child1->geometry()));
351  QCOMPARE(child1->takePaintedRegions(), QRegion(child1->rect()));
352 
353  child1->move(20, 30);
354  QVERIFY(widget.waitForPainted());
355  // both the old and the new area covered by child1 need to be repainted
356  QCOMPARE(widget.takePaintedRegions(), QRegion(20, 20, child1->width(), child1->height() + 10));
357  QCOMPARE(child1->takePaintedRegions(), QRegion(child1->rect()));
358 
359  TestWidget *child2 = new TestWidget(&widget);
360  child2->move(30, 30);
361  child2->raise();
362  child2->show();
363 
364  QVERIFY(child2->waitForPainted());
365  QCOMPARE(widget.takePaintedRegions(), QRegion(child2->geometry()));
366  QCOMPARE(child1->takePaintedRegions(), QRegion(10, 0, child2->width() - 10, child2->height()));
367  QCOMPARE(child2->takePaintedRegions(), QRegion(child2->rect()));
368 
369  child1->hide();
370  QVERIFY(widget.waitForPainted());
371  QCOMPARE(widget.paintedRegions, QRegion(child1->geometry()));
372 }
373 
374 void tst_QWidgetRepaintManager::opaqueChildren()
375 {
376  if (QStringList{"android"}.contains(QGuiApplication::platformName()))
377  QSKIP("This test fails on Android");
378 
380  widget.initialShow();
381 
382  TestWidget *child1 = new TestWidget(&widget);
383  child1->move(20, 20);
385  child1->show();
386 
387  QVERIFY(child1->waitForPainted());
388  QCOMPARE(widget.takePaintedRegions(), QRegion());
389  QCOMPARE(child1->takePaintedRegions(), child1->rect());
390 
391  child1->move(20, 30);
392  QVERIFY(widget.waitForPainted());
393  QCOMPARE(widget.takePaintedRegions(), QRegion(20, 20, child1->width(), 10));
394  if (!m_implementsScroll)
395  QEXPECT_FAIL("", "child1 shouldn't get painted, we can just move the area of the backingstore", Continue);
396  QCOMPARE(child1->takePaintedRegions(), QRegion());
397 }
398 
403 void tst_QWidgetRepaintManager::staticContents()
404 {
407  widget.initialShow();
408 
409  const QSize oldSize = widget.size();
410 
411  widget.resize(widget.width() + 10, widget.height());
412 
413  QVERIFY(widget.waitForPainted());
414  QEXPECT_FAIL("", "This should just repaint the newly exposed region", Continue);
415  QCOMPARE(widget.takePaintedRegions(), QRegion(oldSize.width(), 0, 10, widget.height()));
416 }
417 
421 void tst_QWidgetRepaintManager::scroll()
422 {
423  if (QStringList{"android"}.contains(QGuiApplication::platformName()))
424  QSKIP("This test fails on Android");
425 
427  widget.initialShow();
428 
429  widget.scroll(10, 0);
430  QVERIFY(widget.waitForPainted());
431  if (!m_implementsScroll)
432  QEXPECT_FAIL("", "This should just repaint the newly exposed region", Continue);
433  QCOMPARE(widget.takePaintedRegions(), QRegion(0, 0, 10, widget.height()));
434 
436  child->move(20, 20);
437  child->initialShow();
438 
439  // a potentially semi-transparent child scrolling needs a full repaint
440  child->scroll(10, 0);
441  QVERIFY(child->waitForPainted());
442  QCOMPARE(child->takePaintedRegions(), child->rect());
443  QCOMPARE(widget.takePaintedRegions(), child->geometry());
444 
445  // a explicitly opaque child scrolling only needs the child to repaint newly exposed regions
446  child->setAttribute(Qt::WA_OpaquePaintEvent);
447  child->scroll(10, 0);
448  QVERIFY(child->waitForPainted());
449  if (!m_implementsScroll)
450  QEXPECT_FAIL("", "This should just repaint the newly exposed region", Continue);
451  QCOMPARE(child->takePaintedRegions(), QRegion(0, 0, 10, child->height()));
452  QCOMPARE(widget.takePaintedRegions(), QRegion());
453 }
454 
455 
456 #if defined(QT_BUILD_INTERNAL)
457 
463 void tst_QWidgetRepaintManager::scrollWithOverlap()
464 {
465  if (QStringList{"android"}.contains(QGuiApplication::platformName()))
466  QSKIP("This test fails on Android");
467 
468  class MainWindow : public QWidget
469  {
470  public:
473  {
474  m_scrollArea = new QScrollArea(this);
475  QWidget *w = new QWidget;
476  w->setPalette(QPalette(Qt::gray));
477  w->setAutoFillBackground(true);
478  m_scrollArea->setWidget(w);
479  m_scrollArea->resize(500, 100);
480  w->resize(5000, 600);
481 
482  m_topWidget = new QWidget(this);
483  m_topWidget->setPalette(QPalette(Qt::red));
484  m_topWidget->setAutoFillBackground(true);
485  m_topWidget->resize(300, 200);
486 
487  resize(600, 300);
488  }
489 
490  void resizeEvent(QResizeEvent *e) override
491  {
493  // move scroll area and top widget to the center of the main window
494  scrollArea()->move((width() - scrollArea()->width()) / 2, (height() - scrollArea()->height()) / 2);
495  topWidget()->move((width() - topWidget()->width()) / 2, (height() - topWidget()->height()) / 2);
496  }
497 
498 
499  inline QScrollArea *scrollArea() const { return m_scrollArea; }
500  inline QWidget *topWidget() const { return m_topWidget; }
501 
502  private:
503  QScrollArea *m_scrollArea;
504  QWidget *m_topWidget;
505  };
506 
507  MainWindow w;
508  w.show();
509 
511 
512  bool result = compareWidget(w.topWidget());
513  // if this fails already, then the system we test on can't compare screenshots from grabbed widgets,
514  // and we have to skip this test. Possible reasons are differences in surface formats or DPI, or
515  // unrelated bugs in QPlatformBackingStore::toImage or QWidget::grab.
516  if (!result)
517  QSKIP("Cannot compare QWidget::grab with QScreen::grabWindow on this machine");
518 
519  // scroll the horizontal slider to the right side
520  {
521  w.scrollArea()->horizontalScrollBar()->setValue(w.scrollArea()->horizontalScrollBar()->maximum());
522  QVERIFY(compareWidget(w.topWidget()));
523  }
524 
525  // scroll the vertical slider down
526  {
527  w.scrollArea()->verticalScrollBar()->setValue(w.scrollArea()->verticalScrollBar()->maximum());
528  QVERIFY(compareWidget(w.topWidget()));
529  }
530 
531  // hide the top widget
532  {
533  w.topWidget()->hide();
534  QVERIFY(compareWidget(w.scrollArea()->viewport()));
535  }
536 
537  // scroll the horizontal slider to the left side
538  {
539  w.scrollArea()->horizontalScrollBar()->setValue(w.scrollArea()->horizontalScrollBar()->minimum());
540  QVERIFY(compareWidget(w.scrollArea()->viewport()));
541  }
542 
543  // scroll the vertical slider up
544  {
545  w.scrollArea()->verticalScrollBar()->setValue(w.scrollArea()->verticalScrollBar()->minimum());
546  QVERIFY(compareWidget(w.scrollArea()->viewport()));
547  }
548 }
549 
554 void tst_QWidgetRepaintManager::overlappedRegion()
555 {
557 
558  if (scene.screen()->availableSize().width() < scene.sizeHint().width()
559  || scene.screen()->availableSize().height() < scene.sizeHint().height()) {
560  QSKIP("The screen on this system is too small for this test");
561  }
562 
563  scene.show();
565 
566  auto overlappedRegion = [](QWidget *widget, bool breakAfterFirst = false){
567  auto *priv = QWidgetPrivate::get(widget);
568  // overlappedRegion works on parent coordinates (crect, i.e. QWidget::geometry)
569  return priv->overlappedRegion(widget->geometry(), breakAfterFirst);
570  };
571 
572  // the yellow child is not overlapped
573  QVERIFY(overlappedRegion(scene.yellowChild).isEmpty());
574  // the green child is partially overlapped by the yellow child, which
575  // is at position -50, -50 relative to the green child (and 100x100 large)
576  QRegion overlap = overlappedRegion(scene.greenChild);
577  QVERIFY(!overlap.isEmpty());
578  QCOMPARE(overlap, QRegion(QRect(-50, -50, 100, 100)));
579  // the red child is completely obscured by the green child, and partially
580  // obscured by the yellow child. How exactly this is divided into rects is
581  // irrelevant for the test.
582  overlap = overlappedRegion(scene.redChild);
583  QVERIFY(!overlap.isEmpty());
584  QCOMPARE(overlap.boundingRect(), QRect(-50, -50, 150, 150));
585 
586  // moving the red child out of obscurity
587  scene.redChild->move(100, 0);
588  overlap = overlappedRegion(scene.redChild);
589  QTRY_VERIFY(overlap.isEmpty());
590 
591  // moving the red child down so it's partially behind the bar
592  scene.redChild->move(100, 100);
593  overlap = overlappedRegion(scene.redChild);
594  QTRY_VERIFY(!overlap.isEmpty());
595 
596  // moving the yellow child so it is partially overlapped by the bar
597  scene.yellowChild->move(200, 200);
598  overlap = overlappedRegion(scene.yellowChild);
599  QTRY_VERIFY(!overlap.isEmpty());
600 }
601 
602 void tst_QWidgetRepaintManager::fastMove()
603 {
605  scene.show();
607 
610 
611  // moving yellow; nothing obscured
612  scene.yellowChild->move(QPoint(25, 0));
613  QVERIFY(repaintManager->dirtyRegion().isEmpty()); // fast move
614  if (m_implementsScroll) {
616  QVERIFY(dirtyRegion(scene.yellowChild).isEmpty());
617  } else {
619  QCOMPARE(dirtyRegion(scene.yellowChild), QRect(0, 0, 100, 100));
620  }
621  QCOMPARE(dirtyRegion(&scene), QRect(0, 0, 25, 100));
622  QVERIFY(compareWidget(&scene));
623 }
624 
625 void tst_QWidgetRepaintManager::moveAccross()
626 {
628  scene.show();
630 
633 
634  for (int i = 0; i < 4; ++i) {
635  scene.greenChild->move(scene.greenChild->pos() + QPoint(25, 0));
636  waitForFlush(&scene);
637  }
638  QVERIFY(compareWidget(&scene));
639 
640  for (int i = 0; i < 16; ++i) {
641  scene.redChild->move(scene.redChild->pos() + QPoint(25, 0));
642  waitForFlush(&scene);
643  }
644  QVERIFY(compareWidget(&scene));
645 
646  for (int i = 0; i < qMin(scene.area->width(), scene.area->height()); i += 25) {
647  scene.yellowChild->move(scene.yellowChild->pos() + QPoint(25, 25));
648  waitForFlush(&scene);
649  }
650  QVERIFY(compareWidget(&scene));
651 }
652 
653 void tst_QWidgetRepaintManager::moveInOutOverlapped()
654 {
656  scene.show();
658 
661 
662  // yellow out
663  scene.yellowChild->move(QPoint(-100, 0));
664  QVERIFY(!repaintManager->dirtyRegion().isEmpty()); // invalid dest rect
666  QVERIFY(waitForFlush(&scene));
667  QVERIFY(compareWidget(&scene));
668 
669  // yellow in, obscured by bar
670  scene.yellowChild->move(QPoint(scene.width() / 2, scene.height() / 2));
671  QVERIFY(!repaintManager->dirtyRegion().isEmpty()); // invalid source rect
673  QVERIFY(waitForFlush(&scene));
674  QVERIFY(compareWidget(&scene));
675 
676  // green out
677  scene.greenChild->move(QPoint(-100, 0));
678  QVERIFY(!repaintManager->dirtyRegion().isEmpty()); // invalid dest rect
680  QVERIFY(waitForFlush(&scene));
681  QVERIFY(compareWidget(&scene));
682 
683  // green back in, obscured by bar
684  scene.greenChild->move(QPoint(scene.area->width() / 2 - 50, scene.area->height() / 2 - 50));
685  QVERIFY(!repaintManager->dirtyRegion().isEmpty()); // invalid source rect
687  QVERIFY(waitForFlush(&scene));
688  QVERIFY(compareWidget(&scene));
689 
690  // red back under green
691  scene.redChild->move(scene.greenChild->pos());
692  QVERIFY(!repaintManager->dirtyRegion().isEmpty()); // destination rect obscured
694  QVERIFY(waitForFlush(&scene));
695  QVERIFY(compareWidget(&scene));
696 }
697 #endif //# defined(QT_BUILD_INTERNAL)
698 
700 #include "tst_qwidgetrepaintmanager.moc"
small capitals from c petite p scientific i
[1]
Definition: afcover.h:80
QWidgetRepaintManager * repaintManager(QWidget &widget)
void mouseMoveEvent(QMouseEvent *e) override
void mousePressEvent(QMouseEvent *e) override
Draggable(const QColor &col, QWidget *parent=nullptr)
void resizeEvent(QResizeEvent *) override
void mouseReleaseEvent(QMouseEvent *) override
QSize sizeHint() const override
Draggable(QWidget *parent=nullptr)
OpaqueWidget(const QColor &col, QWidget *parent=nullptr)
void paintEvent(QPaintEvent *e) override
static QWidgetList topLevelWidgets()
The QBackingStore class provides a drawing area for QWindow.
Definition: qbackingstore.h:60
QPlatformBackingStore * handle() const
QWindow * window() const
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:66
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
static QColor fromRgb(QRgb rgb) noexcept
Definition: qcolor.cpp:2366
void setBlue(int blue)
Definition: qcolor.cpp:1594
QGraphicsObject * parent
the parent of the item
qreal height() const
qreal width() const
The QGuiApplication class manages the GUI application's control flow and main settings.
QScreen * primaryScreen
the primary (or default) screen of the application.
QString platformName
The name of the underlying platform plugin.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:73
QImage copy(const QRect &rect=QRect()) const
Definition: qimage.cpp:1197
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
Definition: qimage.cpp:3843
Format format() const
Definition: qimage.cpp:2119
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Definition: qimage.h:160
virtual QRect geometry() const =0
bool isEmpty() const noexcept
Definition: qlist.h:418
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:231
The QObject class is the base class of all Qt objects.
Definition: qobject.h:125
QObject * parent() const
Definition: qobject.h:409
friend class QWidget
Definition: qobject.h:445
void setObjectName(const QString &name)
Definition: qobject.cpp:1261
The QPaintEvent class contains event parameters for paint events. \inmodule QtGui.
Definition: qevent.h:539
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:82
void drawText(const QPointF &p, const QString &s)
Definition: qpainter.cpp:5444
void fillRect(const QRectF &, const QBrush &)
Definition: qpainter.cpp:6644
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:55
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Definition: qpalette.h:179
@ Window
Definition: qpalette.h:87
virtual QImage toImage() const
virtual bool scroll(const QRegion &area, int dx, int dy)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:242
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:52
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:59
constexpr QPoint topLeft() const noexcept
Definition: qrect.h:248
constexpr int width() const noexcept
Definition: qrect.h:263
The QRegion class specifies a clip region for a painter.
Definition: qregion.h:63
QRect boundingRect() const noexcept
bool isEmpty() const
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
Definition: qevent.h:612
QRect geometry
the screen's geometry in pixels
Definition: qscreen.h:81
The QScrollArea class provides a scrolling view onto another widget.
Definition: qscrollarea.h:53
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:55
constexpr int width() const noexcept
Definition: qsize.h:157
static QString number(int, int base=10)
Definition: qstring.cpp:7538
The QStringList class provides a list of strings.
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
void setAutoFillBackground(bool enabled)
Definition: qwidget.cpp:361
void setAttribute(Qt::WidgetAttribute, bool on=true)
Definition: qwidget.cpp:11088
void repaint()
Definition: qwidget.cpp:10899
QWidget * window() const
Definition: qwidget.cpp:4319
void setGeometry(int x, int y, int w, int h)
Definition: qwidget.h:919
void raise()
Definition: qwidget.cpp:11707
void scroll(int dx, int dy)
Definition: qwidget.cpp:10815
QSize size
the size of the widget excluding any window frame
Definition: qwidget.h:147
QRect geometry
the geometry of the widget relative to its parent and excluding the window frame
Definition: qwidget.h:140
void setPalette(const QPalette &)
Definition: qwidget.cpp:4536
QPalette palette
the widget's palette
Definition: qwidget.h:166
int width
the width of the widget excluding any window frame
Definition: qwidget.h:148
QPoint pos
the position of the widget within its parent widget
Definition: qwidget.h:145
void move(int x, int y)
Definition: qwidget.h:913
void hide()
Definition: qwidget.cpp:8078
int height
the height of the widget excluding any window frame
Definition: qwidget.h:149
QRect rect
the internal geometry of the widget excluding any window frame
Definition: qwidget.h:150
void show()
Definition: qwidget.cpp:7825
void update()
Definition: qwidget.cpp:10977
void resize(int w, int h)
Definition: qwidget.h:916
virtual void resizeEvent(QResizeEvent *event)
Definition: qwidget.cpp:9723
bool isWindow() const
Definition: qwidget.h:844
QBackingStore * backingStore() const
Definition: qwidget.cpp:12097
static QWidgetPrivate * get(QWidget *w)
Definition: qwidget_p.h:252
QWidgetRepaintManager * maybeRepaintManager() const
Definition: qwidget_p.h:879
QRegion dirty
Definition: qwidget_p.h:691
QList< QWidget * > dirtyWidgetList() const
QSize sizeHint() const override
void resizeEvent(QResizeEvent *) override
TestWidget(QWidget *parent=nullptr)
QSize sizeHint() const override
void paintEvent(QPaintEvent *event) override
bool waitForPainted(int timeout=5000)
float factor
QOpenGLWidget * widget
[1]
a resize(100000)
double e
QCOMPARE(spy.count(), 1)
Q_TESTLIB_EXPORT const char * currentTestFunction()
Definition: qtestcase.cpp:2749
Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout=5000)
Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout=5000)
Q_TESTLIB_EXPORT const char * currentDataTag()
Definition: qtestcase.cpp:2758
Definition: qnamespace.h:55
@ AlignCenter
Definition: qnamespace.h:188
@ WA_StaticContents
Definition: qnamespace.h:313
@ WA_OpaquePaintEvent
Definition: qnamespace.h:312
@ gray
Definition: qnamespace.h:64
@ white
Definition: qnamespace.h:62
@ blue
Definition: qnamespace.h:68
@ yellow
Definition: qnamespace.h:71
@ darkGray
Definition: qnamespace.h:63
@ green
Definition: qnamespace.h:67
@ red
Definition: qnamespace.h:66
@ HorPattern
Definition: qnamespace.h:1149
@ VerPattern
Definition: qnamespace.h:1150
@ WindowStaysOnTopHint
Definition: qnamespace.h:258
#define QString()
Definition: parse-defines.h:51
QT_END_INCLUDE_NAMESPACE typedef double qreal
Definition: qglobal.h:341
#define qDebug
[1]
Definition: qlogging.h:177
#define qWarning
Definition: qlogging.h:179
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLbitfield GLuint64 timeout
[4]
GLdouble GLdouble right
GLint GLsizei width
GLint left
GLint GLint bottom
GLenum GLuint GLintptr offset
struct _cl_event * event
Definition: qopenglext.h:2998
GLuint64EXT * result
[6]
Definition: qopenglext.h:10932
#define Q_ASSERT(cond)
Definition: qrandom.cpp:84
SSL_CTX int(*) void arg)
#define QTEST_MAIN(TestObject)
Definition: qtest.h:664
#define QSKIP(statement,...)
Definition: qtestcase.h:222
#define QEXPECT_FAIL(dataIndex, comment, mode)
Definition: qtestcase.h:224
#define QVERIFY(statement)
Definition: qtestcase.h:64
#define QTRY_VERIFY(expr)
Definition: qtestcase.h:196
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define slots
Definition: qtmetamacros.h:76
Q_UNUSED(salary)
[21]
QGraphicsScene scene
[0]
QLayoutItem * child
[0]
QPainter painter(this)
[7]
MainWindow()
Definition: whatsthis.cpp:61