PDA

View Full Version : Error Comes in connet the signal and slot.



ashishsaryar
1st February 2008, 15:54
QGraphicsBlockItem::QGraphicsBlockItem(QRectF rt,QGraphicsItem *parent)
: QGraphicsItem(parent)
{
setHandlesChildEvents(true);
m_rtBlock = rt;
m_bOnlyOnce = true;
myparent = parent;
setSelected (true ) ;
connect ( this , SIGNAL ( groupRectItems() ), parent , SLOT( groupedRectBlock() ) );
}

I have writeen Slot in its parent ..
The following erro is coming .
Pls say o me how it will emove andwhat is reason of this eroor.
Error:

c:\Documents and Settings\ashishk\Desktop\MulteMathTool\graphicsblo ckitem.cpp(15): error C2664: 'bool QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 3 from 'QGraphicsItem *' to 'const QObject *'

jacek
1st February 2008, 16:26
QGraphicsItem doesn't inherit QObject, so it can't have any slots.

momesana
2nd February 2008, 23:15
Needles to say, you can inherit from both QGraphicsItem and QObject thus enabling your objects to have slots. Make sure QObject is the put before QGraphicsItem (and other classes) in the class declaration:



class MyItem : public QObject, public QGraphicsItem
{
Q_OBJECT
public:
...
};