// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QGuiApplication>
#include <QList>
#include <qqmlengine.h>
#include <qqmlcontext.h>
#include <qqml.h>
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include "dataobject.h"
/*
This example illustrates exposing a QList<QObject*> as a
model in QML
*/
//![0]
int main(int argc, char ** argv)
{
QGuiApplication app(argc, argv);
const QStringList colorList = {"red", "green", "blue", "yellow"};
const QStringList moduleList = {"Core", "GUI", "Multimedia", "Multimedia Widgets", "Network",
"QML", "Quick", "Quick Controls", "Quick Dialogs",
"Quick Layouts", "Quick Test", "SQL", "Widgets", "3D",
"Android Extras", "Bluetooth", "Concurrent", "D-Bus",
"Gamepad", "Graphical Effects", "Help", "Image Formats",
"Location", "Mac Extras", "NFC", "OpenGL", "Platform Headers",
"Positioning", "Print Support", "Purchasing", "Quick Extras",
"Quick Timeline", "Quick Widgets", "Remote Objects", "Script",
"SCXML", "Script Tools", "Sensors", "Serial Bus",
"Serial Port", "Speech", "SVG", "UI Tools", "WebEngine",
"WebSockets", "WebView", "Windows Extras", "XML",
"XML Patterns", "Charts", "Network Authorization",
"Virtual Keyboard", "Quick 3D", "Quick WebGL"};
QList<QObject *> dataList;
for (const QString &module : moduleList)
dataList.append(new DataObject("Qt " + module, colorList.at(rand() % colorList.length())));
QQuickView view;
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setInitialProperties({{ "model", QVariant::fromValue(dataList) }});
//![0]
view.setSource(QUrl("qrc:/objectlistmodel/view.qml"));
view.show();
return app.exec();
}
没有合适的资源?快使用搜索试试~ 我知道了~
《QML和Qt Quick快速入门》示例源码
共743个文件
qml:286个
qmlproject:212个
png:73个
5星 · 超过95%的资源 需积分: 0 90 下载量 16 浏览量
2023-09-16
19:25:23
上传
评论
收藏 224.14MB ZIP 举报
温馨提示
《QML和Qt Quick快速入门》示例源码.zip
资源推荐
资源详情
资源评论
收起资源包目录
《QML和Qt Quick快速入门》示例源码 (743个子文件)
qtquickcontrols2.conf 86B
main.cpp 2KB
model.cpp 1KB
main.cpp 1KB
main.cpp 876B
main.cpp 835B
main.cpp 824B
dataobject.cpp 793B
main.cpp 596B
main.cpp 585B
main.cpp 552B
main.cpp 533B
main.cpp 533B
main.cpp 530B
main.cpp 528B
main.cpp 495B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 395B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 368B
main.cpp 327B
backend.cpp 318B
main.cpp 250B
main.cpp 250B
main.cpp 250B
main.cpp 250B
main.cpp 250B
Monkey.dae 135KB
Qt6Gui.dll 9.15MB
Qt6Core.dll 6.18MB
Qt6Quick.dll 5.7MB
Qt6Qml.dll 4.92MB
libstdc++-6.dll 1.87MB
Qt6Network.dll 1.57MB
qwindows.dll 1002KB
Qt6QmlModels.dll 726KB
Qt6OpenGL.dll 553KB
Qt6QmlWorkerScript.dll 80KB
libgcc_s_seh-1.dll 74KB
libwinpthread-1.dll 52KB
qtquick2plugin.dll 30KB
workerscriptplugin.dll 30KB
helloworld.exe 231KB
animation.gif 170KB
model.h 931B
dataobject.h 834B
backend.h 569B
island.hdr 64.51MB
snow.hdr 34.46MB
bg.hdr 1.58MB
bg.hdr 1.58MB
bg.hdr 1.58MB
bg.hdr 1.58MB
bg.hdr 1.58MB
myico.ico 158KB
desktop.ini 96B
basecolor.jpg 707KB
metallic.jpg 611KB
bigImage.jpg 590KB
roughness.jpg 587KB
02.jpg 128KB
bigImage.jpg 86KB
bigImage.jpg 86KB
bigImage.jpg 86KB
componentCreation.js 705B
factorial.js 305B
my_button_impl.js 268B
dataloader.js 253B
factorial.js 134B
script.js 78B
island.ktx 255.94MB
monkey.mesh 169KB
__.mesh 169KB
script.mjs 220B
factorial.mjs 159B
music.mp3 182KB
music.mp3 178KB
sphere.png 2.22MB
01.png 1.66MB
floor.png 1.22MB
3.png 1.18MB
2.png 1.04MB
speaker.png 766KB
共 743 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
- 茶水先生2024-04-15好,有良心
weixin_51061632
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功