From 43325a23f35bce7eddfb2e74d2a65d381b1c6aa0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 28 Sep 2012 17:22:21 +0200 Subject: Delete the QVariant ctors taking global Qt enum values. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They have unexpected results in Qt 5 (the Qt::GlobalColor one works as expected in Qt 4, but was removed in Qt 5): QVariant v = QVariant(Qt::red); qDebug() << v; // QVariant(int, 7) v = Qt::red; qDebug() << v; // QVariant(int, 7) The correct way is to use: QVariant v = QVariant::fromValue(QColor(Qt::red)); The deleted constructors are the ones for which there is a class with an implicit constructor taking the enum, and that class is a built-in metatype. QLocale::Language and QKeySequence::StandardKey would also fit the description, but I can't include the header for QKeySequence as it is in QtGui, and I don't want to include the qlocale header in qvariant.h. Putting a QLocale::Language is probably very uncommon anyway. The QTextFormat test is doing the wrong thing, but the result isn't being tested. Added new tests which fail before the patch. Change-Id: Ia38a0784990f4d40ff7457a86daf58aabd4964eb Reviewed-by: Jędrzej Nowacki --- examples/widgets/animation/stickman/lifecycle.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'examples/widgets/animation') diff --git a/examples/widgets/animation/stickman/lifecycle.cpp b/examples/widgets/animation/stickman/lifecycle.cpp index d09d110118..09dec07dfe 100644 --- a/examples/widgets/animation/stickman/lifecycle.cpp +++ b/examples/widgets/animation/stickman/lifecycle.cpp @@ -114,9 +114,9 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) // Make it blink when lightning strikes before entering dead animation QState *lightningBlink = new QState(m_machine); - lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::white); - lightningBlink->assignProperty(m_stickMan, "penColor", Qt::black); - lightningBlink->assignProperty(m_stickMan, "fillColor", Qt::white); + lightningBlink->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::white)); + lightningBlink->assignProperty(m_stickMan, "penColor", QColor(Qt::black)); + lightningBlink->assignProperty(m_stickMan, "fillColor", QColor(Qt::white)); lightningBlink->assignProperty(m_stickMan, "isDead", true); //! [5] @@ -128,9 +128,9 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) //! [5] m_dead = new QState(m_machine); - m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", Qt::black); - m_dead->assignProperty(m_stickMan, "penColor", Qt::white); - m_dead->assignProperty(m_stickMan, "fillColor", Qt::black); + m_dead->assignProperty(m_stickMan->scene(), "backgroundBrush", QColor(Qt::black)); + m_dead->assignProperty(m_stickMan, "penColor", QColor(Qt::white)); + m_dead->assignProperty(m_stickMan, "fillColor", QColor(Qt::black)); m_dead->setObjectName("dead"); // Idle state (sets no properties) -- cgit v1.2.3