max2g
23rd February 2008, 13:05
Can someone tell me what's wrong with the following code:
GKey gg1(1, "Hi");
int id = qRegisterMetaType<GKey>("GKey");
QVariant testV(id, &gg1);
GKey gg2;
if (testV.canConvert<GKey>())
gg2 = testV.value<GKey>();
The last line gives the following error :
"error: no matching function for call to `GKey::GKey(GKey)"
The GKey.h file contains :
#ifndef KEY_H
#define KEY_H
#include "SmartPtr.h"
#include <QList>
#include <QMetaType>
class GKey : public QObject
{
public:
GKey();
GKey(long type, QString uuid);
virtual ~GKey();
const GKey& operator=(const GKey& key);
virtual bool operator==(const GKey& key) const;
virtual bool operator!=(const GKey& key) const;
inline long getType() { return type_; };
void setType(long type) {type_ = type;};
inline QString getUuid() { return uuid_; };
void setUuid(QString uuid) {uuid_ = uuid;};
static long getMetaNo(){ return 6000;};
explicit GKey(const GKey& key);
explicit GKey(const GKey* key);
void copy(const GKey& key);
void free();
void initializeGKey(long constructorType);
void finishGKey(long constructorType);
protected:
long type_;
QString uuid_;
long constructorType_;
};
Q_DECLARE_METATYPE(GKey)
typedef SmartPtr<GKey> SmartPtrGKey;
typedef QList< SmartPtrGKey > SmartPtrGKeyList;
#endif
Thank you !
GKey gg1(1, "Hi");
int id = qRegisterMetaType<GKey>("GKey");
QVariant testV(id, &gg1);
GKey gg2;
if (testV.canConvert<GKey>())
gg2 = testV.value<GKey>();
The last line gives the following error :
"error: no matching function for call to `GKey::GKey(GKey)"
The GKey.h file contains :
#ifndef KEY_H
#define KEY_H
#include "SmartPtr.h"
#include <QList>
#include <QMetaType>
class GKey : public QObject
{
public:
GKey();
GKey(long type, QString uuid);
virtual ~GKey();
const GKey& operator=(const GKey& key);
virtual bool operator==(const GKey& key) const;
virtual bool operator!=(const GKey& key) const;
inline long getType() { return type_; };
void setType(long type) {type_ = type;};
inline QString getUuid() { return uuid_; };
void setUuid(QString uuid) {uuid_ = uuid;};
static long getMetaNo(){ return 6000;};
explicit GKey(const GKey& key);
explicit GKey(const GKey* key);
void copy(const GKey& key);
void free();
void initializeGKey(long constructorType);
void finishGKey(long constructorType);
protected:
long type_;
QString uuid_;
long constructorType_;
};
Q_DECLARE_METATYPE(GKey)
typedef SmartPtr<GKey> SmartPtrGKey;
typedef QList< SmartPtrGKey > SmartPtrGKeyList;
#endif
Thank you !