PDA

View Full Version : error: expected class-name before ‘{’ token



roncriss
10th November 2008, 13:35
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!!!!

spirit
10th November 2008, 13:51
are you sure that Ui::SortDialog correct name?
PS. use tags code

roncriss
10th November 2008, 14:41
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'

pastor
10th November 2008, 16:14
Where primaryColumnCombo, secondaryColumnCombo and tertiaryColumnCombo were declared? It seems, they are not members of SortDialog. Please show us code where you create them