PDA

View Full Version : Problems with QObject



janorcutt
21st February 2010, 12:19
hey peeps, just a quick one. Here is the header for a class i'm writing but when i compile i get:

error: ‘QObject& QObject::operator=(const QObject&)’ is private within this context
and it points to the line containing the opening brace of the class.... any thoughts would be appreciated thanx.



#include <QObject>
#include <QVariant>
#include <QString>

class mediaItem : public QObject
{
Q_OBJECT
public:
explicit mediaItem(QObject *parent = 0);
mediaItem(const mediaItem&);

enum FileType { OGG , FLAC , MP3 , M4A , WAV };
QString filename() { return m_filename; }
QString title() { return m_title; }
QString artist() { return m_artist; }
QString album() { return m_album; }
QVariant duration() { return m_duration; }
QVariant bpm() { return m_bpm; }
QVariant bitrate() { return m_bitrate; }
QVariant tracknum() { return m_tracknum; }
QVariant discnum() { return m_discnum; }
int filetype() { return m_filetype; }

signals:

public slots:
void setfilename(QString filename);
void settitle(QString title);
void setartist(QString artist);
void setalbum(QString album);
void setduration(QVariant duration);
void setbpm(QVariant bpm);
void setbitrate(QVariant bitrate);
void settracknum(QVariant tracknum);
void setdiscnum(QVariant discnum);
void setfiletype(int type);

private:
QString m_filename;
QString m_title;
QString m_artist;
QString m_album;
QVariant m_duration;
QVariant m_bpm;
QVariant m_bitrate;
QVariant m_tracknum;
QVariant m_discnum;
FileType m_filetype;

};


janorcutt:confused:

squidge
21st February 2010, 12:25
any particular reason you are inheriting QObject?

janorcutt
21st February 2010, 12:42
seemed like a good idea at the time

Lykurg
21st February 2010, 14:44
I am not sure but it could be because of the "explicit" in front of your c-tor. Try to compile without it. If all works you probably have a line like
mediaItem item;
item = /* any other QObject */