Error :: extra qualification



  • I am doing the example on dialogs from C++ gui programming with QT 4

    I have finddialog.h
    as
    [code]
    #ifndef FINDDIALOG_H
    #define FINDDIALOG_H
    #include <QDialog>
    class QCheckBox;
    class QLabel;
    class QLineEdit;
    class QPushButton;

    class FindDialog : public QDialog
    {
    Q_OBJECT

    public :
    FindDialog(QWidget *parent = 0);

    signals:
    void findNext(const QString &str,Qt::CaseSensitivity cs);
    void findPrevious(const QString &str,Qt::CaseSensitivity cs);

    private slots:
    void findClicked();
    void enableFindButton(const QString &text);
    private:
    QLabel *label;
    QLineEdit *lineEdit;
    QCheckBox *caseCheckBox;
    QCheckBox *backwardCheckBox;
    QPushButton *findButton;
    QPushButton *closeButton;
    #endif
    [/code]

    finddialog.cpp
    [code]
    #include <QtGui>
    #include "finddialog.h"
    FindDialog::FindDialog(QWidget *parent) : QDialog(parent)
    {
    label = new QLabel(tr("Find &what:"));
    lineEdit = new QLineEdit;
    label->setBuddy(lineEdit);

     caseCheckBox = new QCheckBox(tr("Match &case"));
     backwardCheckBox = new QCheckBox(tr("Search &backward"));
     
     findButton = new QPushButton(tr("&Find"));
     findButton->setDefault(true);
     findButton->setEnabled(false);
     closeButton = new QPushButton(tr("Close"));
    
    connect(lineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(enableFindButton(const QString &)));
    connect(findButton,SIGNAL(clicked()),this,SLOT(findClicked()));
    connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
    
    QHBoxLayout *topLeftLayout = new QHBoxLayout;
    

    topLeftLayout->addWidget(label);
    topLeftLayout->addWidget(lineEdit);

    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addLayout(topLeftLayout);
    leftLayout->addWidget(findButton);
    leftLayout->addWidget(backwardCheckBox);

    QVBoxLayout *rightLayout = new QVBoxLayout;
    rightLayout->addLayout(leftLayout);
    rightLayout->addLayout(rightLayout);
    rightLayout->addStretch();

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(leftLayout);
    mainLayout->addLayout(rightLayout);
    setLayout(mainLayout);

    setWindowTitle(tr("Find"));
    setFixedHeight(sizeHint().height());
    }

    void FindDialog :: findClicked()
    {
    QString text = lineEdit->text();
    Qt:: CaseSensitivity cs = caseCheckBox->isChecked() ? Qt::CaseSensitive
    : Qt::CaseInsensitive;
    if(backwardCheckBox->isChecked()) {
    emit findPrevious(text,cs);
    }
    else{
    emit findNext(text,cs);
    }
    }
    void FindDialog :: enableFindButton(const QString &text)
    {
    findButton->setEnabled(!text.isEmpty());

    }
    }
    [/code]

    main.cpp
    [code]
    #include <QApplication>
    #include "finddialog.h>
    int main(int argc,char *argv[])
    {
    QApplication app(argc,argv);
    FindDialog *dialog = new FindDialog;
    dialog->show();
    return app.exec();
    }
    [/code]

    [code]
    utkarsh@utkarsh-laptop:~/programming/qt/dialog$ ls
    dialog.pro finddialog.cpp finddialog.h main.cpp Makefile
    utkarsh@utkarsh-laptop:~/programming/qt/dialog$ make
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o finddialog.o finddialog.cpp
    finddialog.cpp:3: error: extra qualification ‘FindDialog::’ on member ‘FindDialog’
    finddialog.cpp:3: error: ‘FindDialog::FindDialog(QWidget*)’ cannot be overloaded
    finddialog.h:14: error: with ‘FindDialog::FindDialog(QWidget*)’
    finddialog.cpp:44: error: extra qualification ‘FindDialog::’ on member ‘findClicked’
    finddialog.cpp:44: error: ‘void FindDialog::findClicked()’ cannot be overloaded
    finddialog.h:21: error: with ‘void FindDialog::findClicked()’
    finddialog.cpp:56: error: extra qualification ‘FindDialog::’ on member ‘enableFindButton’
    finddialog.cpp:56: error: ‘void FindDialog::enableFindButton(const QString&)’ cannot be overloaded
    finddialog.h:22: error: with ‘void FindDialog::enableFindButton(const QString&)’
    finddialog.cpp:60: error: expected unqualified-id at end of input
    make: *** [finddialog.o] Error 1
    utkarsh@utkarsh-laptop:~/programming/qt/dialog$ nano finddialog.cpp
    utkarsh@utkarsh-laptop:~/programming/qt/dialog$
    [/code]


  • Moderators

    @void FindDialog :: findClicked()@

    Should be

    @
    void FindDialog::findClicked()@

    Without the spaces

    Do the same for the other error.

    The compiler is complaining because the definition in the header seems repeated in the cpp file.



  • Still getting the error!!
    [code]
    utkarsh@utkarsh-laptop:~/programming/qt/dialog$ make
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o finddialog.o finddialog.cpp
    finddialog.cpp:3: error: extra qualification ‘FindDialog::’ on member ‘FindDialog’
    finddialog.cpp:3: error: ‘FindDialog::FindDialog(QWidget*)’ cannot be overloaded
    finddialog.h:14: error: with ‘FindDialog::FindDialog(QWidget*)’
    finddialog.cpp:44: error: extra qualification ‘FindDialog::’ on member ‘findClicked’
    finddialog.cpp:44: error: ‘void FindDialog::findClicked()’ cannot be overloaded
    finddialog.h:21: error: with ‘void FindDialog::findClicked()’
    finddialog.cpp:56: error: extra qualification ‘FindDialog::’ on member ‘enableFindButton’
    finddialog.cpp:56: error: ‘void FindDialog::enableFindButton(const QString&)’ cannot be overloaded
    finddialog.h:22: error: with ‘void FindDialog::enableFindButton(const QString&)’
    finddialog.cpp:60: error: expected unqualified-id at end of input
    make: *** [finddialog.o] Error 1
    [/code]


  • Moderators

    My previous answer was just a guess without trying it out.

    Now I've tried it and i'm not getting those errors.

    how did you put your code here? Are you sure it's the same as in your project?

    what OS and Qt version are you using?


  • Moderators

    You do not have matching curled braces in FindDialog.cpp. At the end you have doubled closing braces.
    Either it is only a problem of posting or it will certainly spoil your compilation.


Log in to reply
 

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