Results 1 to 3 of 3

Thread: error:expected class name before {

  1. #1

    Default error:expected class name before {

    Can someone help with this error?

    server.h file...

    #ifndef SERVER_H
    #define SERVER_H
    #include <QDialog>
    #include <QtSql>
    //#include <QtDebug>
    #include <QtGui/QApplication>
    #include "server.h"

    namespace Ui {
    class server;
    }

    class server: public QMainWindow
    {
    Q_OBJECT

    public:
    explicit server(QWidget *parent = 0);
    ~server();

    private:
    Ui::server *ui;

    private slots:
    void showcandidates();
    void showballots();
    void showvoters();
    };

    #endif


    server.cpp file...

    #include <QTableView>
    //#include <QtDebug>
    #include <QtSql>
    #include "server.h"
    #include "ui_server.h"
    #include <QApplication>





    server::server(QWidget *parent) :
    QMainWindow(parent);
    ui(new Ui::server)

  2. #2
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error:expected class name before {

    Do you realize that server.h includes itself?

  3. #3
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error:expected class name before {

    It looks like QMainWindow is unknown in your server.h file. QApplication and QDialog don't include it for you. You should probably do something like:
    Qt Code:
    1. ...
    2. #include <QtGui/QMainWindow>
    3. ...
    4. class server : public QMainWindow
    5. {
    6. ...
    To copy to clipboard, switch view to plain text mode 

    Please use code tags when posting code. It improves readability.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. Replies: 13
    Last Post: 19th May 2010, 05:34
  2. error: expected class-name before '{' token
    By Aresti in forum Qt Programming
    Replies: 1
    Last Post: 12th November 2008, 20:00
  3. Replies: 3
    Last Post: 10th November 2008, 16:14
  4. Replies: 4
    Last Post: 22nd February 2008, 19:08
  5. Replies: 2
    Last Post: 30th January 2008, 20:06

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.