Results 1 to 5 of 5

Thread: error: expected class-name before '{' token

  1. #1
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default error: expected class-name before '{' token

    Hello, I've been pulling my hair out trying to figure out how to fix this. I don't have a lot of experience with OOP, so I'm at a bit of a dead end. I am using qt 4.3.3 with visual studio 2005 express.

    I am getting an error:

    ------ Build started: Project: RoboSearch, Configuration: Debug Win32 ------
    Performing Makefile project actions
    mingw32-make -f Makefile.Debug
    saveDOM.cpp:11:20: warning: extra tokens at end of #include directive
    saveDOM.cpp:12:21: warning: extra tokens at end of #include directive
    In file included from saveDOM.cpp:12:
    saveDOM.h:20: error: expected class-name before '{' token
    In file included from saveDOM.cpp:12:
    saveDOM.h:31:7: warning: no newline at end of file
    mingw32-make[1]: *** [debug/saveDOM.o] Error 1
    mingw32-make[1]: Leaving directory `c:/Documents and Settings/abrounstein/My Documents/Visual Studio 2005/Projects/RoboSearch/RoboSearch'
    mingw32-make: *** [debug] Error 2
    Build log was saved at "file://c:\Documents and Settings\abrounstein\My Documents\Visual Studio 2005\Projects\RoboSearch\RoboSearch\Debug\BuildLog .htm"
    RoboSearch - 1 error(s), 3 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    The header file is this:



    Qt Code:
    1. #ifndef SAVEDOM_H
    2. #define SAVEDOM_H
    3.  
    4. #include <Qt>
    5. #include <QtGui>
    6. #include <QLabel>
    7. #include "ui_saveDOM.h"
    8. #include "qdom.h"
    9. #include <QDomDocument>
    10. #include <QDir>
    11.  
    12. class saveDOM : public QMainWindow, private Ui::saveDOM
    13. { //line 22
    14. ...
    15. };
    16. #endif
    To copy to clipboard, switch view to plain text mode 



    The .cpp file currently empty (although it wasn't at one point, it didn't change the errors)

    What is strange is that I literally copied this from another header file in the same project which compiles and runs fine. When I take out the inheritence, I still seem to get the same problem. And yes, I am using the same compilier.

    I originally posted this in a c++ forum, but I talked to someone I work with who is an experience programmer, but he said my code seemed sound to him. Is it maybe a qt problem?

    Does anyone have any suggestions? Thanks!

    Let me know if more information is needed.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error: expected class-name before '{' token

    Could you attach relevant files?
    • ui_saveDOM.h
    • saveDOM.h
    • saveDOM.cpp
    J-P Nurmi

  3. #3
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error: expected class-name before '{' token

    Yes, here they are. They are not the only files in the project, and they are just skeletons right now, while I try to get this to work.
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error: expected class-name before '{' token

    Quote Originally Posted by abrou View Post
    saveDOM.cpp:11:20: warning: extra tokens at end of #include directive
    saveDOM.cpp:12:21: warning: extra tokens at end of #include directive
    Qt Code:
    1. #include "saveDOM.h"; // <-- remove ";"
    2. #include <QtDebug>; // <-- remove ";"
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by abrou View Post
    In file included from saveDOM.cpp:12:
    saveDOM.h:20: error: expected class-name before '{' token
    Qt Code:
    1. class saveDOM : public QMainWindow, private Ui:savedom // <-- should be "Ui::MainWindow" (*)
    To copy to clipboard, switch view to plain text mode 
    (*) because that's how the form was named in Qt Designer
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    abrou (22nd February 2008)

  6. #5
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: error: expected class-name before '{' token

    That's it, thanks!

Similar Threads

  1. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  2. Need help integrating sigc++ with a KDE3/Qt3 app
    By Valheru in forum Qt Programming
    Replies: 1
    Last Post: 17th November 2007, 15:39
  3. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  4. Replies: 2
    Last Post: 4th May 2006, 19:17
  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.