Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community. By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails. I am doing the example on dialogs from C++ gui programming with QT 4 I have finddialog.h as [code] ifndef FINDDIALOG_Hdefine FINDDIALOG_Hinclude <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);
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] error: Date.cpp:16:12: error: extra qualification ‘Time::’ on member ‘operator+’ [-fpermissive] const Time Time::operator+(const Time &other) ; What is this? How do I remove this error? it run fine with Visual Studio
line 16 - 19 and 83 -85 Last edited on Learn to indent.
as you can see, it is obvious of which class the function is a member of, so there is no need to put `Time::' in the declaration. |