Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

KDAB contributions to Qt 5.2

Contributions to Qt by employer (excluding Digia), from here

QDate d(2013, 12, 11);
QVariant v(d);
qDebug() << v.toString(); // prints "2013-12-11"
MyDate d2(2013, Dec, 11); // custom date class
QVariant v2 = QVariant::fromValue(d2);
qDebug() << v2.toString(); // prints ""
QString myDateToString(const MyDate &d)
    return QString("%1-%2-%3").arg(d.year()).arg(d.month()).arg(d.day());
// ...
qDebug() << v2.canConvert()<QString> << v2.toString(); // prints "false """
QMetaType::registerConverter(&myDateToString);
qDebug() << v2.canConvert()<QString> << v2.toString(); // prints "true 2013-12-11"
QList<int> intList;
intList << 42 << 51 << -24;
QVariant variant = QVariant::fromValue(intList);
if (variant.canConvert<QSequentialIterable>()) {
    QSequentialIterable iterable = variant.value<QSequentialIterable>();
    QSequentialIterable::const_iterator it = iterable.begin();
    const QSequentialIterable::const_iterator end = iterable.end();
    for ( ; it != end; ++it) {
        qDebug() << *it;
    }
}
class MyObject : public QObject
{
    Q_OBJECT
    // ...
}
QSharedPointer<MyObject> sp = QSharedPointer::create(arg1, arg2);
QVariant v = QVariant::fromValue(sp);
QObject *obj = v.value<QObject *>(); // works in 5.2

9 Comments

12 - Dec - 2013

Joakim D

14 - Dec - 2013

Slavina

17 - Dec - 2013

Giuseppe D'Angelo

8 - May - 2014

banwenxiaoyu

25 - Jun - 2014

Giuseppe D'Angelo

25 - Jun - 2014

JinYan

25 - Jun - 2014

Giuseppe D'Angelo

26 - Jun - 2014

JinYan

29 - Sept - 2014

mfojtak

GiuseppeD'Angelo

Giuseppe D’Angelo

Senior Software Engineer