WA_UpdatesDisabled = 10,
WA_Mapped = 11,
WA_MacNoClickThrough = 12, // Mac only
- WA_PaintOutsidePaintEvent = 13,
WA_InputMethodEnabled = 14,
WA_WState_Visible = 15,
WA_WState_Hidden = 16,
require native painting primitives, you need to reimplement
QWidget::paintEngine() to return 0 and set this flag.
- \value WA_PaintOutsidePaintEvent Makes it possible to use QPainter to
- paint on the widget outside \l{QWidget::paintEvent()}{paintEvent()}. This
- flag is not supported on Windows, Mac OS X or Embedded Linux. We recommend
- that you use it only when porting Qt 3 code to Qt 4.
-
\value WA_PaintUnclipped Makes all painters operating on this widget
unclipped. Children of this widget or other widgets in front of it do not
clip the area the painter can paint on. This flag is only supported for
\warning When the paintdevice is a widget, QPainter can only be
used inside a paintEvent() function or in a function called by
- paintEvent(); that is unless the Qt::WA_PaintOutsidePaintEvent
- widget attribute is set. On Mac OS X and Windows, you can only
- paint in a paintEvent() function regardless of this attribute's
- setting.
+ paintEvent().
\tableofcontents
d->engine->state = d->state;
switch (pd->devType()) {
-#if 0
- // is this needed any more??
- case QInternal::Widget:
- {
- const QWidget *widget = static_cast<const QWidget *>(pd);
- Q_ASSERT(widget);
-
- const bool paintOutsidePaintEvent = widget->testAttribute(Qt::WA_PaintOutsidePaintEvent);
- const bool inPaintEvent = widget->testAttribute(Qt::WA_WState_InPaintEvent);
-
- // Adjust offset for alien widgets painting outside the paint event.
- if (!inPaintEvent && paintOutsidePaintEvent && !widget->internalWinId()
- && widget->testAttribute(Qt::WA_WState_Created)) {
- const QPoint offset = widget->mapTo(widget->nativeParentWidget(), QPoint());
- d->state->redirectionMatrix.translate(offset.x(), offset.y());
- }
- break;
- }
-#endif
case QInternal::Pixmap:
{
QPixmap *pm = static_cast<QPixmap *>(pd);
paintEngine->d_func()->systemClip = QRegion();
}
q->setAttribute(Qt::WA_WState_InPaintEvent, false);
- if (q->paintingActive() && !q->testAttribute(Qt::WA_PaintOutsidePaintEvent))
+ if (q->paintingActive())
qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
if (paintEngine && paintEngine->autoDestruct()) {
QWidgetBackingStore::unflushPaint(q, toBePainted);
#endif
- if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive())
+ if (q->paintingActive())
qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
}
QTest::newRow("WA_RightToLeft") << Qt::WA_RightToLeft << true;
QTest::newRow("WA_SetStyle") << Qt::WA_SetStyle << true;
QTest::newRow("WA_Resized") << Qt::WA_Resized << true;
- QTest::newRow("unsupported") << Qt::WA_PaintOutsidePaintEvent << false;
}
// void setAttribute(Qt::WidgetAttribute attribute, bool on = true) public
QFETCH(Qt::WidgetAttribute, attribute);
QFETCH(bool, supported);
SubQGraphicsWidget widget;
- if (attribute == Qt::WA_PaintOutsidePaintEvent)
- QTest::ignoreMessage(QtWarningMsg, "QGraphicsWidget::setAttribute: unsupported attribute 13");
widget.setAttribute(attribute);
QCOMPARE(widget.testAttribute(attribute), supported);
}
#endif
void windowFlags();
void initialPosForDontShowOnScreenWidgets();
-#ifdef Q_WS_X11
- void paintOutsidePaintEvent();
-#endif
void updateOnDestroyedSignal();
void toplevelLineEditFocus();
void inputFocus_task257832();
}
}
-#ifdef Q_WS_X11
-void tst_QWidget::paintOutsidePaintEvent()
-{
- QWidget widget;
- widget.resize(200, 200);
-
- QWidget child1(&widget);
- child1.resize(100, 100);
- child1.setPalette(Qt::red);
- child1.setAutoFillBackground(true);
-
- QWidget child2(&widget);
- child2.setGeometry(50, 50, 100, 100);
- child2.setPalette(Qt::blue);
- child2.setAutoFillBackground(true);
-
- widget.show();
- QTest::qWaitForWindowShown(&widget);
- QTest::qWait(60);
-
- const QPixmap before = QPixmap::grabWindow(widget.winId());
-
- // Child 1 should be clipped by child 2, so nothing should change.
- child1.setAttribute(Qt::WA_PaintOutsidePaintEvent);
- QPainter painter(&child1);
- painter.fillRect(child1.rect(), Qt::red);
- painter.end();
- XSync(QX11Info::display(), false); // Flush output buffer.
- QTest::qWait(60);
-
- const QPixmap after = QPixmap::grabWindow(widget.winId());
-
- QCOMPARE(before, after);
-}
-#endif
-
class MyEvilObject : public QObject
{
Q_OBJECT