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)实现业务逻辑?如果可以,大概的思路是怎么样?
 

-----------------------------

题主你好,你说的这种思路是目前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++ 混合编程详解

还有这个制作五子棋小游戏的教程,非常有意思。:
用的Qt Quick版本较老,但思路可以借鉴。

不谢。

编辑于 2014-08-18

-----------------------------

关于QML和C++的集成,参考文档:

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

原文地址:https://www.cnblogs.com/lsgxeva/p/10578362.html