Invalid conversion in a simple 'hello world' zero widget cmake project on app.exec();
Solved
Qt Creator and other tools
-
wrote on 31 Jul 2018, 12:44 last edited by
Hi,
I hope I posted on the right subforum.
I created a very, very simple project without any widgets in the QApplication object and tried to run it.
The code:#include <QApplication> int main(int argc, char* argv[]) { QApplication qapp(argc, argv); return qapp.exec; }
cmake .pro:
QT += core gui greaterThan(QT_MAJOR_VERSION, 4) : QT += widgets SOURCES += \ sause.cpp
I get the following error on compile-time:
sause.cpp:5: error: invalid conversion from 'int (*)()' to 'int' [-fpermissive] return qapp.exec; ^
I think the code is fine, because argv should point to the first element in the array of argv[], no problem there. To be sure though, I tried converting argv into a memory path (&argv), but that didn't work.
Anything I could try? Is this an installation problem? Missing kits, bad compiler?
-
Hi, welcome to the forum.
The error says it:error: invalid conversion from 'int (*)()' to 'int'
which means you're trying to convert a function pointer to an int.Change
return qapp.exec; //taking an address of a function
to
return qapp.exec(); //calling a function
and you'll be good to go.
-
wrote on 31 Jul 2018, 13:00 last edited by TheTobruk
I am so dumb :D
1/3