qml(Qt Quick)做界面
qml(Qt Quick)做界面
来源 https://www.zhihu.com/question/24880681/answer/29324824
本人是Qt初学者,正在写一个会计小软件(Linux桌面版)。看了Qt的介绍,觉得用qml(Qt Quick)做界面非常机动快速,但是qml(Qt Quick)处理复杂的业务逻辑就有点力不从心了。
不知道能否用qml(Qt Quick)做界面,用C++(Qt)实现业务逻辑?如果可以,大概的思路是怎么样?
不知道能否用qml(Qt Quick)做界面,用C++(Qt)实现业务逻辑?如果可以,大概的思路是怎么样?
-----------------------------
题主你好,你说的这种思路是目前Digia主推的一种思路。(今年去参加Qt开发者大会的时候,几乎一半的讲座都会推荐这种用法。)
所以,如何结合QML和C++,官网上会有很多的例子和教程,希望你仔细看看。(另外,鉴于4.8时代的Qt Quick的问题(bug)还不少,所以建议使用最新版的Qt5.3+来做这样的试验。)
这是我随手找到的:Introduction_to_Qt_Quick_for_Cpp_developers
Writing QML Extensions with C++
一个更详尽的例子:
Qt Quick 之 QML 与 C++ 混合编程详解
还有这个制作五子棋小游戏的教程,非常有意思。:http://quitcoding.com/download/Qt_Quick_Game_Programming_1_0.pdf
用的Qt Quick版本较老,但思路可以借鉴。
不谢。
-----------------------------
关于QML和C++的集成,参考文档:http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html
QtQuickControls以及QtQuickControls2的最新进展,
QtCS2015 QtQuickControls2
Background
QtQuick.Controls 1 has tons and tons of objects per control
Overview
QtQuick.Controls 2 has interaction logic in C++, greatly decreases object overhead and number of contexts
QtQuick.Controls 2 has visual items still in a (thin) QML layer
Styling, theming and customization
Native/platform styles currently out of scope
Would be in a separate (derived) imports?
Currently QtQuick.Controls 2 has a simple themable QML layer
Ongoing work adapting the palette concept from widgets (QTBUG-45839)
Parts of controls can be replaced with custom delegates
Status
Popup items vs. popup windows
Text selection handles via IM
No scaling (logical units?) thought of yet
Discussion
Accessibility in the QML layer? Needed as it's private from QtQuick
Some embedded users don't want accessibility. Seems "Short-sighted".
Continue with controls 1 until native/desktop gets brought into the controls 2 idea
As in done and maintained, but R&D on controls 2
大家可以参考:
=============== End
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2018-03-22 将网卡更改为混杂模式
2018-03-22 Linux 网桥配置命令:brctl
2018-03-22 mysql之 mysql数据库压力测试工具(mysqlslap)