.pro
+++++++++++++++++++++++++++++++++++++++++++++
#-------------------------------------------------
#
# Project created by QtCreator 2012-03-15T09:57:33
#
#-------------------------------------------------
QT += declarative quick
TARGET = Qt5Test
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.qml
main.cpp
+++++++++++++++++++++++++++++++++++++++++++++++++++
#include <QQuickView>#include <QGuiApplication>#include <QDeclarativeEngine>#include <QObject>Q_DECL_EXPORT int main(int argc, char *argv[]){QGuiApplication app(argc, argv, 5);QQuickView viewer;QObject::connect(viewer.engine(), SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));viewer.setSource(QUrl::fromLocalFile("test.qml"));viewer.show();return app.exec();}.qml+++++++++++++++++++++++++++++++++++++++++++++++++++++import QtQuick 2.0Rectangle {width: 640height: 480Text {anchors.centerIn: parenttext: qsTr("\u6211\u662f\u4e2d\u6587Hello Qt")}MouseArea {anchors.fill: parentonClicked: {Qt.quit();}}}参考:http://qt-project.org/forums/%20/viewthread/13857http://qt-project.org/forums/viewthread/6907

本文介绍如何使用Qt5与Visual Studio 2008进行编译,包含.pro文件配置、源文件main.cpp及.qml文件的示例代码。通过简单的Qt5应用程序示例,展示了如何创建和运行一个包含QML界面的应用。
206

被折叠的 条评论
为什么被折叠?



