QML 工程中调用 widgets
Pro文件中添加 QT += core gui widgets quick
#include <QGuiApplication>
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <mainwindowvm.h>
int main(int argc, char* argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject* obj, const QUrl& objUrl)
{
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
MainWindowVM MainWindowVM;
XXXXXXXXXXXXXXXtName("aaaaa");
XXXXXXXXXotContext()->setContextProperty(QT_STRINGIFY(MainWindowVM), &MainWindowVM);
return app.exec();
}
QGuiApplication 改为 QApplication 注意添加 QApplication 头文件
时段 | 个数 |
---|---|
{{f.startingTime}}点 - {{f.endTime}}点 | {{f.fileCount}} |