Hi,
I'm trying Qt Creator for developing my application but build fail with the following error:
error: cannot call member function ‘bool QDir::exists(const QString&) const’ without object
The error points to the if() of the following function:
void AddressbookDialog::on_addPushButton_clicked()
{
if(!QDir::exists(fileName
)) { //...
}
//...
}
void AddressbookDialog::on_addPushButton_clicked()
{
QFile file;
QString fileName = QDir::homePath() + QDir::separator() + ".kesemes.xml";
if(!QDir::exists(fileName)) {
//...
}
//...
}
To copy to clipboard, switch view to plain text mode
This is the constructor:
AddressbookDialog
::AddressbookDialog(QWidget *parent
) : m_ui(new Ui::AddressbookDialog)
{
m_ui->setupUi(this);
}
AddressbookDialog::AddressbookDialog(QWidget *parent) :
QDialog(parent),
m_ui(new Ui::AddressbookDialog)
{
m_ui->setupUi(this);
}
To copy to clipboard, switch view to plain text mode
and this is the header:
#ifndef ADDRESSBOOKDIALOG_H
#define ADDRESSBOOKDIALOG_H
#include <QtGui/QDialog>
namespace Ui {
class AddressbookDialog;
}
class AddressbookDialog
: public QDialog { Q_OBJECT
Q_DISABLE_COPY(AddressbookDialog)
public:
explicit AddressbookDialog
(QWidget *parent
= 0);
virtual ~AddressbookDialog();
protected:
virtual void changeEvent
(QEvent *e
);
private:
Ui::AddressbookDialog *m_ui;
private slots:
void on_closePushButton_clicked();
void on_addPushButton_clicked();
void on_editPushButton_clicked();
};
#endif // ADDRESSBOOKDIALOG_H
#ifndef ADDRESSBOOKDIALOG_H
#define ADDRESSBOOKDIALOG_H
#include <QtGui/QDialog>
namespace Ui {
class AddressbookDialog;
}
class AddressbookDialog : public QDialog {
Q_OBJECT
Q_DISABLE_COPY(AddressbookDialog)
public:
explicit AddressbookDialog(QWidget *parent = 0);
virtual ~AddressbookDialog();
protected:
virtual void changeEvent(QEvent *e);
private:
Ui::AddressbookDialog *m_ui;
private slots:
void on_closePushButton_clicked();
void on_addPushButton_clicked();
void on_editPushButton_clicked();
};
#endif // ADDRESSBOOKDIALOG_H
To copy to clipboard, switch view to plain text mode
Where is my error?
Thanks
Bookmarks