Skip to content

Commit 2c64b1d

Browse files
usiemsmrbean-bremen
authored andcommitted
Comparison rules of QVariant have changed in Qt6
1 parent 8545458 commit 2c64b1d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

tests/PythonQtTests.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,15 @@ void PythonQtTestApi::testVariables()
512512
QVariant v2 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someObject2");
513513
QVERIFY(v2==QVariant());
514514

515-
PythonQt::self()->addVariable(PythonQt::self()->getMainModule(), "someValue", QStringList() << "test1" << "test2");
515+
QVariant someValue = QStringList() << "test1" << "test2";
516+
PythonQt::self()->addVariable(PythonQt::self()->getMainModule(), "someValue", someValue);
516517
QVariant v3 = PythonQt::self()->getVariable(PythonQt::self()->getMainModule(), "someValue");
517-
QVERIFY(v3 == QVariant(QStringList() << "test1" << "test2"));
518+
#if QT_VERSION >= 0x060000
519+
// In Qt6 the behavior of the == operator changed, and it will not try to convert the other
520+
// value first, so we replicate this first (otherwise the comparison QVariantList <-> QStringList fails)
521+
QVERIFY(someValue.convert(v3.metaType()));
522+
#endif
523+
QVERIFY(v3 == someValue);
518524

519525
QStringList l = PythonQt::self()->introspection(PythonQt::self()->getMainModule(), QString::null, PythonQt::Variable);
520526
QSet<QString> s;

0 commit comments

Comments
 (0)