Results 1 to 2 of 2

Thread: ‘QLabel& QLabel::operator=(const QLabel&)’ is private error when using vectors

  1. #1
    Join Date
    Sep 2009
    Posts
    60
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default ‘QLabel& QLabel::operator=(const QLabel&)’ is private error when using vectors

    I get this error when I am trying to use a vector with values that are a custom class. The custom class inherits QLabel.

    I have:

    Qt Code:
    1. class SomeClass : public QLabel {
    2. .
    3. .
    4. };
    To copy to clipboard, switch view to plain text mode 
    I create a vector of SomeClass:
    Qt Code:
    1. vector<SomeClass> foo;
    To copy to clipboard, switch view to plain text mode 
    and then when I do:
    Qt Code:
    1. foo.push_back(NULL);
    To copy to clipboard, switch view to plain text mode 
    I get this error. In eclipse there is a red underline under "class SomeClass : public QLabel {"

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 162 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: ‘QLabel& QLabel::operator=(const QLabel&)’ is private error when using vectors

    two errors here:
    i) you can not copy QObjects (or subclasses like QWidgets), thus you can not put them in containers by value; you can use QList<SomeClass*>, though.
    ii) NULL is a pointer, whereas your vector wants an object, which is why you'd get an error even if QLabel was copyable

    HTH

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.