Results 1 to 3 of 3

Thread: error: 'connect' was not declared in this scope ??

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default error: 'connect' was not declared in this scope ??

    error: 'connect' was not declared in this scope

    this is the error I get when trying to compile this code:



    Qt Code:
    1. ------ cpp file --------
    2.  
    3. #include "Fraga.h"
    4. #include <QtGui>
    5. #include <QtCore>
    6. Fraga::Fraga()
    7. {
    8. _nyttsvar = new QAction("new answer",0);
    9. qDebug()<<"hej"<<connect(_nyttsvar,SIGNAL(triggered()),this,SLOT(addNewSvar()));
    10. }
    11. ----------- h file-----------
    12. #ifndef FRAGA_H
    13. #define FRAGA_H
    14. #include <QtCore>
    15. #include <QtGui>
    16.  
    17. class Fraga:public QGraphicsRectItem{
    18. Q_OBJECT
    19. public:
    20. Fraga();
    21. public slots:
    22. void addNewSvar();
    23. protected:
    24. QAction* _nyttsvar;
    25. };
    26.  
    27.  
    28. #endif
    To copy to clipboard, switch view to plain text mode 

    I do not understand what's wrong.

  2. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: error: 'connect' was not declared in this scope ??

    Quote Originally Posted by Morea View Post
    Qt Code:
    1. class Fraga:public QGraphicsRectItem{
    2. Q_OBJECT
    3. public:
    4. Fraga();
    To copy to clipboard, switch view to plain text mode 

    I do not understand what's wrong.
    You are forgetting a fact that QGraphics*Item do not inherit QObject and connect method is provided by QObject.
    Try this, it should most probably work

    Qt Code:
    1. class Fraga : public QObject, public QGraphicsRectItem
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: 'connect' was not declared in this scope ??

    Great. It works now.

Similar Threads

  1. Installation on Fedora Core 4
    By jcr in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2009, 01:34
  2. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 19:11
  3. Fed up with M$ Window$ !!! Why is Tux leaving me alone???
    By fullmetalcoder in forum General Discussion
    Replies: 35
    Last Post: 18th March 2006, 12:57
  4. Am I the only one with "make" error ?
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 12:54
  5. Qt 4.1 and KDE 3.5.1 on OSX 10.2.8
    By Ptero-4 in forum Installation and Deployment
    Replies: 6
    Last Post: 6th February 2006, 02:44

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.