I am new to Qt. I am creating simple qml application. Qt Version :- QMake version 2.01a Using Qt version 4.6.2 I am on Linux system. I have created qml containing two buttons(button.qml) and also created c++ code(main.cpp).
Code for main.cpp
#include<QtGui/QApplication>
#include<QtGui/QLabel>
#include"qmlapplicationviewer.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QmlApplicationViewer viewer;
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.setMainQmlFile(QLatin1String("button.qml"));
viewer.showExpanded();
a.exec();
}
I am compiling it with qmake && make
and got error as
qmlapplicationviewer.h: No such file or directory
QmlApplicationViewerâ was not declared in this scope
I tried to search for "qmlapplicationviewer.h" and "QmlApplicationViewer" on my system. But unable to find it.
Please help.
I would not use the application viewer for such a simple case, so I would drop it. I would write something like this:
#include <QDeclarativeView>
#include <QApplication>
int main(int argc, char **argv)
{
QApplication app( argc, argv );
QDeclarativeView view;
view.setSource(QUrl("button.qml"));
view.showFullScreen();
return app.exec();
}
If you really wish to use the qml application viewer, you could obtain the header and source file from here , and add them to the corresponding HEADERS
and SOURCES
variables in your project file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.