Expected class name error

  • 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
        SortDialog(QWidget* parent = 0);
        void setColumnRange(QChar first, QChar last);
    #endif // SORTDIALOG_H

  • Qt Champions 2016

    Syntax is correct, it probably complains about Ui::SortDialog. Perhaps your form isn't called SortDialog? Go in the designer and make sure the form's (top-level widget's) name is matching the class name you're using.

  • This is my form:

    alt text

    What do you mean by "form's (top-level widget's)" please?

  • Qt Champions 2016

    @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 be Ui::MainWindow. Make sure your top level widget (the one that's on top of everything else) is called SortDialog.

    Kind regards.

  • I changed the Form's objectname to SortDialog and the bug fixed!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.