Expected class name error
-
wrote on 11 Jan 2017, 19:12 last edited by
Hi all,
This is the .h file of a program. I face the following error but whatever I look I can't find out why Qt creator's compiler shows that error! Would you please have a look at it?
C:\Users\ME\Documents\Qt\Sort\sortdialog.h:8: error: expected class-name before '{' token
{
^
The.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 // SORTDIALOG_H
-
@tomy said in Expected class name error:
What do you mean by "form's (top-level widget's)" please?
This is what I mean. The first object's name is how the class will be called. In my case it's the "inventive"
MainWindow
, thus the generated class will beUi::MainWindow
. Make sure your top level widget (the one that's on top of everything else) is calledSortDialog
.Kind regards.
-
Hi all,
This is the .h file of a program. I face the following error but whatever I look I can't find out why Qt creator's compiler shows that error! Would you please have a look at it?
C:\Users\ME\Documents\Qt\Sort\sortdialog.h:8: error: expected class-name before '{' token
{
^
The.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 // SORTDIALOG_H
Syntax is correct, it probably complains about
Ui::SortDialog
. Perhaps your form isn't calledSortDialog
? Go in the designer and make sure the form's (top-level widget's) name is matching the class name you're using. -
wrote on 11 Jan 2017, 19:39 last edited by tomy 1 Nov 2017, 19:40
-
@tomy said in Expected class name error:
What do you mean by "form's (top-level widget's)" please?
This is what I mean. The first object's name is how the class will be called. In my case it's the "inventive"
MainWindow
, thus the generated class will beUi::MainWindow
. Make sure your top level widget (the one that's on top of everything else) is calledSortDialog
.Kind regards.
-
wrote on 11 Jan 2017, 20:40 last edited by
I changed the Form's objectname to SortDialog and the bug fixed!
Thanks.
1/5