QApplication, QLabel : no such file or directory
-
Hello,
I'm a QT beginner. I have been trying to execute below code. But I continuously get 'QApplication and QLabel : no such file or directory' error. I referred to a couple of past posts and tried but failed. Can someone help me with this issue?
I have also added "QT += widgets, core gui" to .pro file.
Thank you#include <QtWidgets/QApplication> #include <QtGui/QLabel> #include <QPixmap> int main(int argc, char** argv){ QApplication app(argc, argv); QLabel* lb = new QLabel("", 0); lb->setPixmap(QPixmap("bali.jpg")); lb->show(); return app.exec(); }
-
@Genne Documentation tells you what to include.
For example https://doc.qt.io/qt-5/qapplication.html#include <QApplication>
-
Hi and welcome to the forums
If you see older examples for Qt, sometimes the includes are no longer valid.
Often you can just remove first part of it
#include <QtWidgets/QApplication>
--->
#include <QApplication>and then it works.
-
Hi,
@Genne said in QApplication, QLabel : no such file or directory:
QT += widgets, core gui
There's a comma after widgets. Is it a typo here or do you also have that in your .pro file ?
-
@jsulm said in QApplication, QLabel : no such file or directory:
@Genne Documentation tells you what to include.
For example https://doc.qt.io/qt-5/qapplication.html#include <QApplication>
I should definitely read it thru. Thank you for the reply
-
PATH ? Why did you change that environment variable manually ?