I'm having troubles with QLabel. This is the code from the book :
// helloWorld/main.cpp
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
label.show();
return a.exec();
}
// helloWorld/main.cpp
#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel label("Hello World");
label.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
main.cpp:2:24: error: QApplication: No such file or directory
main.cpp:3:18: error: QLabel: No such file or directory
main.cpp: In function 'int main(int, char**)':
main.cpp:7: error: 'QApplication' was not declared in this scope
main.cpp:7: error: expected `;' before 'a'
main.cpp:8: error: 'QLabel' was not declared in this scope
main.cpp:8: error: expected `;' before 'label'
main.cpp:9: error: 'label' was not declared in this scope
main.cpp:10: error: 'a' was not declared in this scope
main.cpp: At global scope:
main.cpp:5: warning: unused parameter 'argc'
main.cpp:5: warning: unused parameter 'argv'
make: *** [main.o] Error 1
Than I change in header QApplication to qapplication.h and QLabel to qlabel.h
// helloWorld/main.cpp
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
label.show();
return a.exec();
}
// helloWorld/main.cpp
#include <qapplication.h>
#include <qlabel.h>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QLabel label("Hello World");
label.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
main.cpp: In function 'int main(int, char**)':
main.cpp:8: error: no matching function for call to 'QLabel::QLabel(const char [12])'
/usr/lib/qt/include/qlabel.h:163: note: candidates are: QLabel::QLabel(const QLabel&)
/usr/lib/qt/include/qlabel.h:66: note: QLabel::QLabel(QWidget*, const QString&, QWidget*, const char*, uint)
/usr/lib/qt/include/qlabel.h:64: note: QLabel::QLabel(const QString&, QWidget*, const char*, uint)
/usr/lib/qt/include/qlabel.h:62: note: QLabel::QLabel(QWidget*, const char*, uint)
make: *** [main.o] Error 1
Can somebody tell me what is wrong with this?
Bookmarks