Last active 1729664657

dylan revised this gist 1729664657. Go to revision

1 file changed, 26 insertions

gistfile1.txt(file created)

@@ -0,0 +1,26 @@
1 + #include <QtGui/QApplication>
2 + #include <QtDeclarative/QDeclarativeView>
3 + #include <QtDeclarative/QDeclarativeContext>
4 + #include "MeeTooter.h" // 引入自定义的 MeeTooter 类
5 +
6 + int main(int argc, char *argv[])
7 + {
8 + QApplication app(argc, argv);
9 +
10 + // 创建一个 QDeclarativeView,显示 QML 界面
11 + QDeclarativeView view;
12 +
13 + // 创建 MeeTooter 实例,并将其导出到 QML 上下文
14 + MeeTooter meeTooter;
15 + view.rootContext()->setContextProperty("meeTooter", &meeTooter);
16 +
17 + // 加载 QML 文件
18 + view.setSource(QUrl::fromLocalFile("/path/to/main.qml"));
19 +
20 + // 设置窗口大小
21 + view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
22 + view.show();
23 +
24 + // 执行应用程序
25 + return app.exec();
26 + }
Newer Older

Powered by Opengist Load: 9ms