Results 1 to 3 of 3

Thread: Error Comes in connet the signal and slot.

  1. #1
    Join Date
    Jul 2007
    Location
    Noida
    Posts
    46
    Thanks
    7
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Error Comes in connet the signal and slot.

    Qt Code:
    1. QGraphicsBlockItem::QGraphicsBlockItem(QRectF rt,QGraphicsItem *parent)
    2. : QGraphicsItem(parent)
    3. {
    4. setHandlesChildEvents(true);
    5. m_rtBlock = rt;
    6. m_bOnlyOnce = true;
    7. myparent = parent;
    8. setSelected (true ) ;
    9. connect ( this , SIGNAL ( groupRectItems() ), parent , SLOT( groupedRectBlock() ) );
    10. }
    To copy to clipboard, switch view to plain text mode 

    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 *'
    Last edited by jpn; 1st February 2008 at 15:29. Reason: reformatted to look better
    Ashish Kumar Saryar

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Error Comes in connet the signal and slot.

    QGraphicsItem doesn't inherit QObject, so it can't have any slots.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Error Comes in connet the signal and slot.

    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:

    Qt Code:
    1. class MyItem : public QObject, public QGraphicsItem
    2. {
    3. Q_OBJECT
    4. public:
    5. ...
    6. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Signal to specific object slot
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2007, 15:51
  2. signal and slot across threads having event loop
    By travis in forum Qt Programming
    Replies: 6
    Last Post: 5th November 2007, 23:56
  3. Replies: 2
    Last Post: 16th August 2007, 00:20
  4. Manually send signal to slot
    By donmorr in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2006, 15:03
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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.