Results 1 to 4 of 4

Thread: error: expected class-name before ‘{’ token

  1. #1
    Join Date
    Oct 2008
    Location
    Dar es Salaam,Tanzania
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default error: expected class-name before ‘{’ token

    Hi guys ,i am a newbie and i am learning Qt.
    i am getting this error when i compile my sortdialog application,i got the code from c++ GUI programming with QT4

    Running build steps for project Sort...
    Configuration unchanged, skipping QMake step.
    Starting: /usr/bin/make debug -w
    make: Entering directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    /usr/bin/make -f Makefile.Debug
    make[1]: Entering directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtNetwork -I/usr/include/QtNetwork -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -Idebug -I. -o debug/main.o main.cpp
    In file included from main.cpp:2:
    sortdialog.h:6: error: expected class-name before ‘{’ token
    make[1]: Leaving directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    make: Leaving directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    make[1]: *** [debug/main.o] Error 1
    make: *** [debug] Error 2
    Exited with code 2.
    Error while building project Sort
    When executing build step 'Make'

    here is my sortdialog.h file
    ************************************************** ****************************
    #ifndef SORTDIALOG_H
    #define SORTDIALOG_H
    #include <QDialog>
    #include "ui_sortdialog.h"
    class SortDialog : public QDialog, public Ui::SortDialog
    {
    Q_OBJECT
    public:
    SortDialog(QWidget *parent = 0);
    void setColumnRange(QChar first, QChar last);
    };
    #endif
    ************************************************** *****************************
    and main.cpp file
    ************************************************** ****************************
    //main.cpp
    #include <QApplication>
    #include "sortdialog.h"
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    SortDialog *dialog = new SortDialog;
    dialog->setColumnRange('C', 'F');
    dialog->show();
    return app.exec();
    }
    ************************************************** *****************************
    sortdialog.cpp file
    ************************************************** *****************************
    1 #include <QtGui>
    2 #include "sortdialog.h"
    3 SortDialog::SortDialog(QWidget *parent)
    4 : QDialog(parent)
    5 {
    6 setupUi(this);
    7 secondaryGroupBox->hide();
    8 tertiaryGroupBox->hide();
    9 layout()->setSizeConstraint(QLayout::SetFixedSize);
    10 setColumnRange('A', 'Z');
    11 }
    12 void SortDialog::setColumnRange(QChar first, QChar last)
    13 {
    14 primaryColumnCombo->clear();
    15 secondaryColumnCombo->clear();
    16 tertiaryColumnCombo->clear();
    17 secondaryColumnCombo->addItem(tr("None"));
    18 tertiaryColumnCombo->addItem(tr("None"));
    19 primaryColumnCombo->setMinimumSize(
    20 secondaryColumnCombo->sizeHint());
    21 QChar ch = first;
    22 while (ch <= last) {
    23 primaryColumnCombo->addItem(QString(ch));
    24 secondaryColumnCombo->addItem(QString(ch));
    25 tertiaryColumnCombo->addItem(QString(ch));
    26 ch = ch.unicode() + 1;
    27 }
    28 }
    ************************************************** ******************************
    please help me solve this problem!!!!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: error: expected class-name before ‘{’ token

    are you sure that Ui::SortDialog correct name?
    PS. use tags code
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2008
    Location
    Dar es Salaam,Tanzania
    Posts
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: expected class-name before ‘{’ token

    Yes i tried to check the objectName of my form and it was Sort so i change it to SortDialog.But now i'm getting another errors..

    Running build steps for project Sort...
    Starting: /usr/bin/qmake /home/roncriss/Desktop/desktop/lab/spreadsheet/Sort/Sort.pro -spec /usr/share/qt4/mkspecs/linux-g++-64 -r CONFIG+=debug_and_release -after SOURCES*=/opt/qtcreator-0.9/bin/gdbmacros/gdbmacros.cpp -after QT*=network
    Exited with code 0.
    Starting: /usr/bin/make debug -w
    make: Entering directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    /usr/bin/make -f Makefile.Debug
    make[1]: Entering directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtNetwork -I/usr/include/QtNetwork -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -Idebug -I. -o debug/sortdialog.o sortdialog.cpp
    sortdialog.cpp: In member function ‘void SortDialog::setColumnRange(QChar, QChar)’:
    sortdialog.cpp:14: error: ‘primaryColumnCombo’ was not declared in this scope
    sortdialog.cpp:15: error: ‘secondaryColumnCombo’ was not declared in this scope
    sortdialog.cpp:16: error: ‘tertiaryColumnCombo’ was not declared in this scope
    make[1]: Leaving directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    make: Leaving directory `/home/roncriss/Desktop/desktop/lab/spreadsheet/Sort'
    make[1]: *** [debug/sortdialog.o] Error 1
    make: *** [debug] Error 2
    Exited with code 2.
    Error while building project Sort
    When executing build step 'Make'

  4. #4
    Join Date
    Oct 2008
    Posts
    70
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Default Re: error: expected class-name before ‘{’ token

    Where primaryColumnCombo, secondaryColumnCombo and tertiaryColumnCombo were declared? It seems, they are not members of SortDialog. Please show us code where you create them

Similar Threads

  1. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  2. How to use Signal through direct connection
    By santosh.kumar in forum Qt Programming
    Replies: 1
    Last Post: 14th December 2007, 07:07
  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.