Custom QGraphicsItems not compiling and gives "object is private" error
        Posted  
        
            by bahree
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by bahree
        
        
        
        Published on 2010-04-20T21:10:28Z
        Indexed on 
            2010/04/20
            22:43 UTC
        
        
        Read the original article
        Hit count: 436
        
Hi, I am trying to create a Custom QGraphicsItem button as shown by Fred here. The code which he posted can be found here.
The problem is when I try and compile the code I get the following two errors:
- /usr/include/qt4/QtGui/qgraphicsitem.h ‘QGraphicsItem::QGraphicsItem(const QGraphicsItem&)’ is private
 - /usr/include/qt4/QtCore/qobject.h
‘QObject::QObject(const QObject&)’ is private 
Here is the code snippet which essentially is the same as that in the sample above. The error is on the class deceleration.
class MyButton : public QObject, public QGraphicsItem
{
 Q_OBJECT
 Q_INTERFACES(QGraphicsItem)
public:
 MyButton(QGraphicsItem *parent = 0);
 MyButton(const QString normal, const QString pressed = "", QGraphicsItem *parent = 0);
....
}
Interestingly the other sample as shown here works fine. The sample code for that can be found here.
Any idea what is wrong? Thanks in advance.
© Stack Overflow or respective owner