I'm using Qt creator 2.0.1
, and when entering this line:
#include <QLabel>
I get the following error:
QLabel: No such file or directory
Why is that? And, how can I include a label in this case?
UPDATE
@maverik showed me how to solve the QLabel
error, but I'm now getting this error:
The program I'm trying to run is:
#include <QtCore/QCoreApplication>
#include <QtGui/QLabel>
int main(int argc, char *argv[]) {
QCoreApplication myapp(argc, argv);
QLabel *label = new QLabel("Hello");
label->show();
return myapp.exec();
}
Any ideas?
Thanks.
Use
QApplication
Rather than
QCoreApplication
.
from the QCoreApplication docs:
The QCoreApplication class provides an event loop for console Qt applications. This class is used by non-GUI applications to provide their event loop. For non-GUI application that uses Qt, there should be exactly one QCoreApplication object. For GUI applications, see QApplication.
Then Include the relevant headers, and it will compile just fine. QCoreApplication is for non-Gui applications (Console).