Results 1 to 13 of 13

Thread: expected type-specifier before 'Class Name' / not declared in this scope

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #12
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: expected type-specifier before 'Class Name' / not declared in this scope

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <myclass.h>
    3. #include "manidialog.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. ManiDialog *w = new ManiDialog( 0 );
    9. MyClass *m = new MyClass();
    10. w->show();
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 
    At line 2 you are asking the pre-processor to look for the file myclass.h in the system include directory path. This path is a compound of a built-in value and any "-I" directives (or equivalents) and typically does not include the current directory. You should be receiving a pre-processor error saying it cannot find myclass.h before you get the error message you are describing here.

    Have you tried:
    Qt Code:
    1. #include "myclass.h"
    To copy to clipboard, switch view to plain text mode 
    The compiler will look in all the same places for the file but it will look in the current (actually same directory as the cpp file) directory first.
    Last edited by ChrisW67; 27th May 2010 at 23:11. Reason: spelling corrections

Similar Threads

  1. `lineEdit' was not declared in this scope?
    By i4ba1 in forum Qt Programming
    Replies: 2
    Last Post: 18th November 2009, 14:36
  2. QDomDocument was not declared in this scope
    By grantbj74 in forum Newbie
    Replies: 5
    Last Post: 25th August 2009, 09:43
  3. glutSolidSphere was not declared in this scope error
    By nuts_fever_007 in forum Qt Programming
    Replies: 2
    Last Post: 15th May 2009, 04:56
  4. Replies: 2
    Last Post: 28th December 2007, 18:30
  5. error: 'connect' was not declared in this scope ??
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2007, 15:27

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
  •  
Qt is a trademark of The Qt Company.