operator<<() and operator>>() Problems
Nathan Osman — 12 years ago


//============
// CKey.h
//============
class CKey
{
/* public default constructor
public copy constructor
public destructor */
};
QDataStream & operator<<(QDataStream &, const CKey &);
QDataStream & operator<<(QDataStream &, CKey &);
Q_DECLARE_METATYPE(CKey)
//============
// CKey.cpp
//============
#include "CKey.h"
QDataStream & operator<<(QDataStream & out, const CKey &) { return out; }
QDataStream & operator>>(QDataStream & in, CKey &) { return in; }
//============
// main.cpp
//============
#include <QtCore/QCoreApplication>
#include <QSettings>
#include "CKey.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
//qRegisterMetaTypeStreamOperators<CKey>("CKey");
QSettings s("temp.ini", QSettings::IniFormat);
s.setValue("Key", QVariant::fromValue<CKey>(CKey()));
return 0;
}