main.cpp Example File | Qt 4.8 (original) (raw)

tools/customtype/main.cpp

#include #include #include "message.h"

int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QStringList headers; headers << "Subject: Hello World" << "From: qt-info@nokia.com"; QString body = "This is a test.\r\n";

Message message(body, headers);
[qDebug](qtglobal.html#qDebug)() << "Original:" << message;

[QVariant](qvariant.html) stored;
stored.setValue(message);

[qDebug](qtglobal.html#qDebug)() << "Stored:" << stored;

Message retrieved = stored.value<Message>();
[qDebug](qtglobal.html#qDebug)() << "Retrieved:" << retrieved;
retrieved = qvariant_cast<Message>(stored);
[qDebug](qtglobal.html#qDebug)() << "Retrieved:" << retrieved;

return 0;

}

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.