Hi, i'm doing an application with Qt/OpenGL and i have some problems with auxiliar functions to open files in Qt.
I receive these errors:
ISO C++ forbids declaration of "open" with no type
ISO C++ forbids declaration of "loadFile" with no type
Printable View
Hi, i'm doing an application with Qt/OpenGL and i have some problems with auxiliar functions to open files in Qt.
I receive these errors:
ISO C++ forbids declaration of "open" with no type
ISO C++ forbids declaration of "loadFile" with no type
Sorry, error typing, i've not finished the text already ^^
You can see here the code of each function:
MenuPrincipal::open()
{
QString fileName = QFileDialog::getOpenFileName(this);
if (!fileName.isEmpty())
loadFile(fileName);
return 0;
}
MenuPrincipal::loadFile(const QString &fileName)
{
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Application"),
tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
return 0;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::restoreOverrideCursor();
setCurrentFile(fileName);
return 0;
}
and the code in the header:
private slots:
int open();
private:
int loadFile(const QString &fileName);
[ Moved thread ]
Just add the int that you have in your header file declarations to the function header introducing the function implementation as well. That's the simple truth this error message is telling you.
Please use code tags when posting code.
Seriously, you can't put this
ISO C++ forbids declaration of "loadFile" with no type
and this
MenuPrincipal::loadFile(const QString &fileName)
together and figure out what you did wrong?