Results 1 to 4 of 4

Thread: Problems with QObject

  1. #1
    Join Date
    Feb 2010
    Location
    Wokingham, United Kingdom
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Question Problems with QObject

    hey peeps, just a quick one. Here is the header for a class i'm writing but when i compile i get:
    Qt Code:
    1. error: ‘QObject& QObject::operator=(const QObject&)’ is private within this context
    To copy to clipboard, switch view to plain text mode 
    and it points to the line containing the opening brace of the class.... any thoughts would be appreciated thanx.

    Qt Code:
    1. #include <QObject>
    2. #include <QVariant>
    3. #include <QString>
    4.  
    5. class mediaItem : public QObject
    6. {
    7. Q_OBJECT
    8. public:
    9. explicit mediaItem(QObject *parent = 0);
    10. mediaItem(const mediaItem&);
    11.  
    12. enum FileType { OGG , FLAC , MP3 , M4A , WAV };
    13. QString filename() { return m_filename; }
    14. QString title() { return m_title; }
    15. QString artist() { return m_artist; }
    16. QString album() { return m_album; }
    17. QVariant duration() { return m_duration; }
    18. QVariant bpm() { return m_bpm; }
    19. QVariant bitrate() { return m_bitrate; }
    20. QVariant tracknum() { return m_tracknum; }
    21. QVariant discnum() { return m_discnum; }
    22. int filetype() { return m_filetype; }
    23.  
    24. signals:
    25.  
    26. public slots:
    27. void setfilename(QString filename);
    28. void settitle(QString title);
    29. void setartist(QString artist);
    30. void setalbum(QString album);
    31. void setduration(QVariant duration);
    32. void setbpm(QVariant bpm);
    33. void setbitrate(QVariant bitrate);
    34. void settracknum(QVariant tracknum);
    35. void setdiscnum(QVariant discnum);
    36. void setfiletype(int type);
    37.  
    38. private:
    39. QString m_filename;
    40. QString m_title;
    41. QString m_artist;
    42. QString m_album;
    43. QVariant m_duration;
    44. QVariant m_bpm;
    45. QVariant m_bitrate;
    46. QVariant m_tracknum;
    47. QVariant m_discnum;
    48. FileType m_filetype;
    49.  
    50. };
    To copy to clipboard, switch view to plain text mode 

    janorcutt

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Problems with QObject

    any particular reason you are inheriting QObject?

  3. #3
    Join Date
    Feb 2010
    Location
    Wokingham, United Kingdom
    Posts
    36
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default Re: Problems with QObject

    seemed like a good idea at the time

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Problems with QObject

    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
    Qt Code:
    1. mediaItem item;
    2. item = /* any other QObject */
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Lykurg for this useful post:

    janorcutt (21st February 2010)

Similar Threads

  1. Having some QObject problems
    By Barvik in forum Qt Programming
    Replies: 7
    Last Post: 13th November 2008, 05:29
  2. tip on using QObject::sender()
    By drhex in forum Qt Programming
    Replies: 1
    Last Post: 3rd April 2008, 21:01
  3. Replies: 1
    Last Post: 31st October 2007, 15:14
  4. help on QObject::tr()
    By sincnarf in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2007, 08:52
  5. QObject inherittance problems
    By KShots in forum Qt Programming
    Replies: 4
    Last Post: 24th April 2007, 17:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.