単純なQMLアプリケーションを作成します
質問
私はQtに新しいです。私は単純なQMLアプリケーションを作成しています。 QTバージョン: - Qmakeバージョン2.01a. QTバージョン4.6.2を使用する 私はLinuxシステムにいます。 2つのボタン(Button.QML)を含むQMLを作成し、C ++コード(Main.cpp)を作成しました。
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();
}
.
qmake && make
でコンパイルしてエラーが発生しました
qmlapplicationviewer.h: No such file or directory
QmlApplicationViewerâ was not declared in this scope
.
私はシステム上の "qmlapplicationViewer.h"と "qmlApplicationViewer"を検索しようとしました。 しかしそれを見つけることができません。
助けてください。
解決
アプリケーションビューアはこのような簡単な場合には使用できないので、それを落とします。私はこのようなものを書くでしょう:
#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();
}
.
QMLアプリケーションビューアを本当に使用したい場合は、ここにを、プロジェクトファイル内の対応するHEADERS
変数とSOURCES
変数に追加します。
所属していません StackOverflow