summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qapplication_win.cpp5
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp7
-rw-r--r--src/openvg/qpaintengine_vg.cpp124
-rw-r--r--tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp297
-rw-r--r--tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp9
5 files changed, 198 insertions, 244 deletions
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index 0a4869b..aac834d 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -1905,8 +1905,13 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
break;
if (!msg.wParam) {
+#ifdef Q_WS_WINCE
+ // On Windows CE, lParam parameter is a constant, not a char pointer.
+ if (msg.lParam == INI_INTL) {
+#else
QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
if (area == QLatin1String("intl")) {
+#endif
QLocalePrivate::updateSystemPrivate();
if (!widget->testAttribute(Qt::WA_SetLocale))
widget->dptr()->setLocale_helper(QLocale(), true);
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index b36294a..c550938 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -5743,6 +5743,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
}
+#ifndef QT_NO_TOOLBAR
+ case SE_ToolBarHandle:
+ if (hasStyleRule(w, PseudoElement_ToolBarHandle))
+ return ParentStyle::subElementRect(se, opt, w);
+ break;
+#endif //QT_NO_TOOLBAR
+
default:
break;
}
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index da47f06..4192dbb 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -131,8 +131,9 @@ public:
void draw(VGPath path, const QPen& pen, const QBrush& brush, VGint rule = VG_EVEN_ODD);
void stroke(VGPath path, const QPen& pen);
void fill(VGPath path, const QBrush& brush, VGint rule = VG_EVEN_ODD);
- VGPath vectorPathToVGPath(const QVectorPath& path);
- VGPath painterPathToVGPath(const QPainterPath& path);
+ inline void releasePath(VGPath path);
+ VGPath vectorPathToVGPath(const QVectorPath& path, bool forceNewPath = false);
+ VGPath painterPathToVGPath(const QPainterPath& path, bool forceNewPath = false);
VGPath roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode);
VGPaintType setBrush
(VGPaint paint, const QBrush& brush, VGMatrixMode mode,
@@ -178,6 +179,8 @@ public:
VGPath roundRectPath; // Cached path for quick drawing of rounded rects.
#endif
+ VGPath reusablePath; // Reusable path for vectorPathToVGPath(), etc.
+
QTransform transform; // Currently active transform.
bool simpleTransform; // True if the transform is simple (non-projective).
qreal penScale; // Pen scaling factor from "transform".
@@ -350,6 +353,8 @@ void QVGPaintEnginePrivate::init()
roundRectPath = 0;
#endif
+ reusablePath = 0;
+
simpleTransform = true;
pathTransformSet = false;
penScale = 1.0;
@@ -446,6 +451,15 @@ void QVGPaintEnginePrivate::initObjects()
VG_PATH_CAPABILITY_ALL);
vgAppendPathData(linePath, 2, segments, coords);
#endif
+
+ // This path can be reused over and over by calling vgClearPath().
+ reusablePath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ 32 + 1, // segmentCapacityHint
+ 32 * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
}
void QVGPaintEnginePrivate::destroy()
@@ -465,6 +479,8 @@ void QVGPaintEnginePrivate::destroy()
if (roundRectPath)
vgDestroyPath(roundRectPath);
#endif
+ if (reusablePath)
+ vgDestroyPath(reusablePath);
#if !defined(QVG_NO_DRAW_GLYPHS)
QVGFontCache::Iterator it;
@@ -541,19 +557,32 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev)
qt_scaleForTransform(transform, &penScale);
}
-VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
+inline void QVGPaintEnginePrivate::releasePath(VGPath path)
+{
+ if (path == reusablePath)
+ vgClearPath(path, VG_PATH_CAPABILITY_ALL);
+ else
+ vgDestroyPath(path);
+}
+
+VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path, bool forceNewPath)
{
int count = path.elementCount();
const qreal *points = path.points();
const QPainterPath::ElementType *elements = path.elements();
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath;
+ if (forceNewPath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ } else {
+ vgpath = reusablePath;
+ }
// Size is sufficient segments for drawRoundedRect() paths.
QVarLengthArray<VGubyte, 20> segments;
@@ -725,17 +754,22 @@ VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
return vgpath;
}
-VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path)
+VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path, bool forceNewPath)
{
int count = path.elementCount();
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath;
+ if (forceNewPath) {
+ vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
+ VG_PATH_DATATYPE_F,
+ 1.0f, // scale
+ 0.0f, // bias
+ count + 1, // segmentCapacityHint
+ count * 2, // coordCapacityHint
+ VG_PATH_CAPABILITY_ALL);
+ } else {
+ vgpath = reusablePath;
+ }
if (count == 0)
return vgpath;
@@ -954,13 +988,7 @@ VGPath QVGPaintEnginePrivate::roundedRectPath(const QRectF &rect, qreal xRadius,
vgModifyPathCoords(vgpath, 0, 9, pts);
}
#else
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 10, // segmentCapacityHint
- 17 * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath vgpath = reusablePath;
vgAppendPathData(vgpath, 10, roundedrect_types, pts);
#endif
@@ -1516,7 +1544,7 @@ void QVGPaintEngine::draw(const QVectorPath &path)
d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
else
d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
@@ -1527,7 +1555,7 @@ void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
d->fill(vgpath, brush, VG_EVEN_ODD);
else
d->fill(vgpath, brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
@@ -1535,7 +1563,7 @@ void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
Q_D(QVGPaintEngine);
VGPath vgpath = d->vectorPathToVGPath(path);
d->stroke(vgpath, pen);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
// Determine if a co-ordinate transform is simple enough to allow
@@ -1731,7 +1759,7 @@ void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
default: break;
}
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
vgSeti(VG_MASKING, VG_TRUE);
d->maskValid = true;
@@ -2048,7 +2076,7 @@ void QVGPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op)
default: break;
}
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
vgSeti(VG_MASKING, VG_TRUE);
d->maskValid = true;
@@ -2487,7 +2515,7 @@ void QVGPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad,
VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
d->draw(vgpath, s->pen, s->brush);
#if defined(QVG_NO_MODIFY_PATH)
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
#endif
} else {
QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
@@ -2636,13 +2664,7 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
Q_D(QVGPaintEngine);
if (d->simpleTransform) {
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 4, // segmentCapacityHint
- 12, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
static VGubyte segments[4] = {
VG_MOVE_TO_ABS,
VG_SCCWARC_TO_REL,
@@ -2666,7 +2688,7 @@ void QVGPaintEngine::drawEllipse(const QRectF &r)
coords[11] = 0.0f;
vgAppendPathData(path, 4, segments, coords);
d->draw(path, s->pen, s->brush);
- vgDestroyPath(path);
+ d->releasePath(path);
} else {
// The projective transform version of an ellipse is difficult.
// Generate a QVectorPath containing cubic curves and transform that.
@@ -2690,7 +2712,7 @@ void QVGPaintEngine::drawPath(const QPainterPath &path)
d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
else
d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
+ d->releasePath(vgpath);
}
void QVGPaintEngine::drawPoints(const QPointF *points, int pointCount)
@@ -2765,13 +2787,7 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
{
Q_D(QVGPaintEngine);
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
QVarLengthArray<VGfloat, 16> coords;
QVarLengthArray<VGubyte, 10> segments;
for (int i = 0; i < pointCount; ++i, ++points) {
@@ -2805,20 +2821,14 @@ void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonD
d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
break;
}
- vgDestroyPath(path);
+ d->releasePath(path);
}
void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
{
Q_D(QVGPaintEngine);
QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
+ VGPath path = d->reusablePath;
QVarLengthArray<VGfloat, 16> coords;
QVarLengthArray<VGubyte, 10> segments;
for (int i = 0; i < pointCount; ++i, ++points) {
@@ -2852,7 +2862,7 @@ void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDr
d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
break;
}
- vgDestroyPath(path);
+ d->releasePath(path);
}
void QVGPaintEnginePrivate::setImageOptions()
@@ -3251,7 +3261,7 @@ void QVGFontGlyphCache::cacheGlyphs
ti.fontEngine->getUnscaledGlyph(glyph, &path, &metrics);
VGPath vgPath;
if (!path.isEmpty()) {
- vgPath = d->painterPathToVGPath(path);
+ vgPath = d->painterPathToVGPath(path, true);
} else {
// Probably a "space" character with no visible outline.
vgPath = VG_INVALID_HANDLE;
diff --git a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
index f21bd44..8c30be4 100644
--- a/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/benchmarks/gui/kernel/qwidget/tst_qwidget.cpp
@@ -42,33 +42,35 @@
#include <qtest.h>
#include <QtGui>
-class tst_QWidget : public QObject
+static void processEvents()
{
- Q_OBJECT
-
-
-private slots:
- void update_data();
- void updateOpaque_data();
- void updateOpaque();
- void updateTransparent_data();
- void updateTransparent();
- void updatePartial_data();
- void updatePartial();
- void updateComplex_data();
- void updateComplex();
-
- void complexToplevelResize();
-};
+ QApplication::flush();
+ QApplication::processEvents();
+ QApplication::processEvents();
+}
class UpdateWidget : public QWidget
{
public:
- UpdateWidget(int rows, int columns) : QWidget(0)
+ UpdateWidget(int rows, int columns)
+ : QWidget(0), rowCount(0), columnCount(0), opaqueChildren(false)
{
+ fill(rows, columns);
+ }
+
+ UpdateWidget(QWidget *parent = 0)
+ : QWidget(parent), rowCount(0), columnCount(0), opaqueChildren(false) {}
+
+ void fill(int rows, int columns)
+ {
+ if (rows == rowCount && columns == columnCount)
+ return;
+ delete layout();
QGridLayout *layout = new QGridLayout;
- for (int row = 0; row < rows; ++row) {
- for (int column = 0; column < columns; ++column) {
+ rowCount = rows;
+ columnCount = columns;
+ for (int row = 0; row < rowCount; ++row) {
+ for (int column = 0; column < columnCount; ++column) {
UpdateWidget *widget = new UpdateWidget;
widget->setFixedSize(20, 20);
layout->addWidget(widget, row, column);
@@ -76,9 +78,20 @@ public:
}
}
setLayout(layout);
+ adjustSize();
+ QTest::qWait(250);
+ processEvents();
}
- UpdateWidget(QWidget *parent = 0) : QWidget(parent) {}
+ void setOpaqueChildren(bool enable)
+ {
+ if (opaqueChildren != enable) {
+ foreach (QWidget *w, children)
+ w->setAttribute(Qt::WA_OpaquePaintEvent, enable);
+ opaqueChildren = enable;
+ processEvents();
+ }
+ }
void paintEvent(QPaintEvent *)
{
@@ -93,75 +106,86 @@ public:
QRegion updateRegion;
QList<UpdateWidget*> children;
+ int rowCount;
+ int columnCount;
+ bool opaqueChildren;
};
-void tst_QWidget::update_data()
+class tst_QWidget : public QObject
{
- QTest::addColumn<int>("rows");
- QTest::addColumn<int>("columns");
- QTest::addColumn<int>("numUpdates");
-
- QTest::newRow("10x10x1") << 10 << 10 << 1;
- QTest::newRow("10x10x10") << 10 << 10 << 10;
- QTest::newRow("25x25x1") << 25 << 25 << 1;
- QTest::newRow("25x25x10") << 25 << 25 << 10;
- QTest::newRow("25x25x100") << 25 << 25 << 100;
-}
+ Q_OBJECT
-void tst_QWidget::updateOpaque_data()
-{
- update_data();
-}
+public slots:
+ void initTestCase();
+ void init();
-void tst_QWidget::updateOpaque()
-{
- QFETCH(int, rows);
- QFETCH(int, columns);
- QFETCH(int, numUpdates);
+private slots:
+ void update_data();
+ void update();
+ void updatePartial_data();
+ void updatePartial();
+ void updateComplex_data();
+ void updateComplex();
- UpdateWidget widget(rows, columns);
- foreach (QWidget *w, widget.children) {
- w->setAttribute(Qt::WA_OpaquePaintEvent);
- }
+private:
+ UpdateWidget widget;
+};
+void tst_QWidget::initTestCase()
+{
widget.show();
- QApplication::processEvents();
+ QTest::qWaitForWindowShown(&widget);
+ QTest::qWait(300);
+ processEvents();
+}
- int i = 0;
- const int n = widget.children.size();
- QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
- widget.children[i]->update();
- QApplication::processEvents();
- i = (i + 1) % n;
- }
- }
+void tst_QWidget::init()
+{
+ QVERIFY(widget.isVisible());
+ for (int i = 0; i < 3; ++i)
+ processEvents();
}
-void tst_QWidget::updateTransparent_data()
+void tst_QWidget::update_data()
{
- update_data();
+ QTest::addColumn<int>("rows");
+ QTest::addColumn<int>("columns");
+ QTest::addColumn<int>("numUpdates");
+ QTest::addColumn<bool>("opaque");
+
+ QTest::newRow("10x10x1 transparent") << 10 << 10 << 1 << false;
+ QTest::newRow("10x10x10 transparent") << 10 << 10 << 10 << false;
+ QTest::newRow("10x10x100 transparent") << 10 << 10 << 100 << false;
+ QTest::newRow("10x10x1 opaque") << 10 << 10 << 1 << true;
+ QTest::newRow("10x10x10 opaque") << 10 << 10 << 10 << true;
+ QTest::newRow("10x10x100 opaque") << 10 << 10 << 100 << true;
+ QTest::newRow("25x25x1 transparent ") << 25 << 25 << 1 << false;
+ QTest::newRow("25x25x10 transparent") << 25 << 25 << 10 << false;
+ QTest::newRow("25x25x100 transparent") << 25 << 25 << 100 << false;
+ QTest::newRow("25x25x1 opaque") << 25 << 25 << 1 << true;
+ QTest::newRow("25x25x10 opaque") << 25 << 25 << 10 << true;
+ QTest::newRow("25x25x100 opaque") << 25 << 25 << 100 << true;
}
-void tst_QWidget::updateTransparent()
+void tst_QWidget::update()
{
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, numUpdates);
+ QFETCH(bool, opaque);
- UpdateWidget widget(rows, columns);
- widget.show();
- QApplication::processEvents();
+ widget.fill(rows, columns);
+ widget.setOpaqueChildren(opaque);
- int i = 0;
- const int n = widget.children.size();
QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
- widget.children[i]->update();
+ for (int i = 0; i < widget.children.size(); ++i) {
+ for (int j = 0; j < numUpdates; ++j)
+ widget.children.at(i)->update();
QApplication::processEvents();
- i = (i + 1) % n;
}
}
+
+ QApplication::flush();
}
void tst_QWidget::updatePartial_data()
@@ -174,24 +198,23 @@ void tst_QWidget::updatePartial()
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, numUpdates);
+ QFETCH(bool, opaque);
- UpdateWidget widget(rows, columns);
- widget.show();
- QApplication::processEvents();
+ widget.fill(rows, columns);
+ widget.setOpaqueChildren(opaque);
- int i = 0;
- const int n = widget.children.size();
QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
+ for (int i = 0; i < widget.children.size(); ++i) {
QWidget *w = widget.children[i];
const int x = w->width() / 2;
const int y = w->height() / 2;
- w->update(0, 0, x, y);
- w->update(x, 0, x, y);
- w->update(0, y, x, y);
- w->update(x, y, x, y);
+ for (int j = 0; j < numUpdates; ++j) {
+ w->update(0, 0, x, y);
+ w->update(x, 0, x, y);
+ w->update(0, y, x, y);
+ w->update(x, y, x, y);
+ }
QApplication::processEvents();
- i = (i + 1) % n;
}
}
}
@@ -206,127 +229,27 @@ void tst_QWidget::updateComplex()
QFETCH(int, rows);
QFETCH(int, columns);
QFETCH(int, numUpdates);
+ QFETCH(bool, opaque);
- UpdateWidget widget(rows, columns);
- widget.show();
- QApplication::processEvents();
+ widget.fill(rows, columns);
+ widget.setOpaqueChildren(opaque);
- int i = 0;
- const int n = widget.children.size();
QBENCHMARK {
- for (int j = 0; j < numUpdates; ++j) {
+ for (int i = 0; i < widget.children.size(); ++i) {
QWidget *w = widget.children[i];
const int x = w->width() / 2;
const int y = w->height() / 2;
- w->update(QRegion(0, 0, x, y, QRegion::Ellipse));
- w->update(QRegion(x, y, x, y, QRegion::Ellipse));
+ QRegion r1(0, 0, x, y, QRegion::Ellipse);
+ QRegion r2(x, y, x, y, QRegion::Ellipse);
+ for (int j = 0; j < numUpdates; ++j) {
+ w->update(r1);
+ w->update(r2);
+ }
QApplication::processEvents();
- i = (i + 1) % n;
}
}
}
-class ResizeWidget : public QWidget
-{
-public:
- ResizeWidget();
-};
-
-ResizeWidget::ResizeWidget() : QWidget(0)
-{
- QBoxLayout *topLayout = new QVBoxLayout;
-
- QMenuBar *menubar = new QMenuBar;
- QMenu* popup = menubar->addMenu("&File");
- popup->addAction("&Quit", qApp, SLOT(quit()));
- topLayout->setMenuBar(menubar);
-
- QBoxLayout *buttons = new QHBoxLayout;
- buttons->setMargin(5);
- buttons->addStretch(10);
- for (int i = 1; i <= 4; i++ ) {
- QPushButton* button = new QPushButton;
- button->setText(QString("Button %1").arg(i));
- buttons->addWidget(button);
- }
- topLayout->addLayout(buttons);
-
- buttons = new QHBoxLayout;
- buttons->addStretch(10);
- for (int i = 11; i <= 16; i++) {
- QPushButton* button = new QPushButton;
- button->setText(QString("Button %1").arg(i));
- buttons->addWidget(button);
- }
- topLayout->addLayout(buttons);
-
- QBoxLayout *buttons2 = new QHBoxLayout;
- buttons2->addStretch(10);
- topLayout->addLayout(buttons2);
-
- QPushButton *button = new QPushButton;
- button->setText("Button five");
- buttons2->addWidget(button);
-
- button = new QPushButton;
- button->setText("Button 6");
- buttons2->addWidget(button);
-
- QTextEdit *bigWidget = new QTextEdit;
- bigWidget->setText("This widget will get all the remaining space");
- bigWidget->setFrameStyle(QFrame::Panel | QFrame::Plain);
- topLayout->addWidget(bigWidget);
-
- const int numRows = 6;
- const int labelCol = 0;
- const int linedCol = 1;
- const int multiCol = 2;
-
- QGridLayout *grid = new QGridLayout;
- for (int row = 0; row < numRows; row++) {
- QLineEdit *lineEdit = new QLineEdit;
- grid->addWidget(lineEdit, row, linedCol);
- QLabel *label = new QLabel(QString("Line &%1").arg(row + 1));
- grid->addWidget(label, row, labelCol);
- }
- topLayout->addLayout(grid);
-
- QTextEdit *multiLineEdit = new QTextEdit;
- grid->addWidget(multiLineEdit, 0, labelCol + 1, multiCol, multiCol);
-
- grid->setColumnStretch(linedCol, 10);
- grid->setColumnStretch(multiCol, 20);
-
- QLabel* statusBar = new QLabel;
- statusBar->setText("Let's pretend this is a status bar");
- statusBar->setFrameStyle(QFrame::Panel | QFrame::Sunken);
- statusBar->setFixedHeight(statusBar->sizeHint().height());
- statusBar->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
- topLayout->addWidget(statusBar);
-
- topLayout->activate();
- setLayout(topLayout);
-}
-
-void tst_QWidget::complexToplevelResize()
-{
- ResizeWidget w;
- w.show();
-
- QApplication::processEvents();
-
- const int minSize = 100;
- const int maxSize = 800;
- int size = minSize;
-
- QBENCHMARK {
- w.resize(size, size);
- size = qMax(minSize, (size + 10) % maxSize);
- QApplication::processEvents();
- QApplication::processEvents();
- }
-}
-
QTEST_MAIN(tst_QWidget)
#include "tst_qwidget.moc"
diff --git a/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp b/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp
index 226b661..d051b12 100644
--- a/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp
+++ b/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp
@@ -82,6 +82,7 @@ void tst_qstylesheetstyle::empty()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet("/*" + QString::number(i) + "*/");
@@ -94,6 +95,7 @@ void tst_qstylesheetstyle::empty_events()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet("/*" + QString::number(i) + "*/");
@@ -112,6 +114,7 @@ void tst_qstylesheetstyle::simple()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet(QString(simple_css) + "/*" + QString::number(i) + "*/");
@@ -124,6 +127,7 @@ void tst_qstylesheetstyle::simple_events()
{
QWidget *w = buildSimpleWidgets();
w->setStyleSheet("/* */");
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet(QString(simple_css) + "/*" + QString::number(i) + "*/");
@@ -175,8 +179,13 @@ void tst_qstylesheetstyle::grid()
w->setStyleSheet("/* */");
if(show) {
w->show();
+ QTest::qWaitForWindowShown(w);
+ QApplication::flush();
+ QApplication::processEvents();
QTest::qWait(30);
+ QApplication::processEvents();
}
+ QApplication::processEvents();
int i = 0;
QBENCHMARK {
w->setStyleSheet(stylesheet + "/*" + QString::number(i) + "*/");