当前位置: 首页 > 工具软件 > Qt Quick > 使用案例 >

Roson讲Qt#17 谈谈Qt QML、Qt Quick、Qt Quick Controls之间的关系

经昱
2023-12-01

目录

1.概念

2.关系和区别

3.扩展

3.1QML语言提供的基本数据类型

3.2QML语言提供的基本对象类型

3.3Qt Quick的子模块

3.4Qt Quick提供的基本数据类型

3.5Qt Quick提供的基本对象类型


1.概念

Qt QML:QML是一种用户界面规范和编程语言。它允许开发人员和设计师一样创建高性能、流畅的动画和视觉上吸引人的应用程序。QML提供了高可读性、声明性、类似json的语法,支持命令式JavaScript表达式和动态属性绑定。QML语言和引擎基础结构由Qt QML模块提供。

Qt Quick模块:Qt Quick是QML的类型和功能的标准库。它包括视觉类型,交互类型,动画,模型和视图,粒子效果和着色效果。QML应用程序开发人员可以通过一个导入语句访问所有这些功能。QtQuick QML库由QtQuick模块提供。

Qt Quick Controls模块:提供了一组控件,可用于在Qt Quick中构建完整的接口。

2.关系和区别

QML是一种编程语言,和C++,C#,Java一样,属于一种编程语言。QML提供一些基本的数据类型。

Qt Quick是一个库,作用和我们说的C++标准库一样,如果要编写C++代码,肯定需要C++标准库的支撑。我们在写Qt Quick应用程序时,肯定需要用到一些数据类型,还有一些语法,而这些东西,就是Qt Quick提供的。在QML已经提供的基础数据类型的基础上,Qt Quick又引入了更高级易用的数据类型,这就好比QML中有char*,Qt Quick又搞了个CString。

Qt Quick Controls是Qt Quick的一个子模块,Qt Quick不仅包含Controls,还包含了
Dialogs、Layouts等模块。

3.扩展

3.1QML语言提供的基本数据类型

dateDate value
pointValue with x and y attributes
rectValue with x, y, width and height attributes
sizeValue with width and height attributes

3.2QML语言提供的基本对象类型

DateProvides date functions
NumberObject provides represents a number value
StringObject represents a string value
ComponentEncapsulates a QML component definition
QtProvides a global object with useful enums and functions from Qt
QtObjectA basic QML type
LocaleProvides locale specific properties and formatted data
LoggingCategoryDefines a logging category in QML
BindingEnables the arbitrary creation of property bindings
ConnectionsDescribes generalized connections to signals
InstantiatorDynamically creates objects
TimerTriggers a handler at a specified interval

3.3Qt Quick的子模块

Qt Quick包含几个子模块,并且这些子模块还包含额外的类型。子模块列举如下:

  • XML List Model - contains types for creating models from XML data
  • Local Storage - a submodule containing a JavaScript interface for an SQLite database
  • Particles - provides a particle system for QML applications
  • Window - contains types for creating top-level windows and accessing screen information
  • Dialogs - contains types for creating and interacting with system dialogs
  • Controls - provides a set of reusable UI components
  • Layouts - contains types that are used to arrange items in the user interface
  • Tests - types for testing QML applications.

3.4Qt Quick提供的基本数据类型

colorARGB color value. The color type refers to an ARGB color value. It can be specified in a number of ways:
fontFont value with the properties of QFont. The font type refers to a font value with the properties of QFont
matrix4x4A matrix4x4 type is a 4-row and 4-column matrix
quaternionA quaternion type has scalar, x, y, and z attributes
vector2dA vector2d type has x and y attributes
vector3dValue with x, y, and z attributes
vector4dA vector4d type has x, y, z and w attributes

3.5Qt Quick提供的基本对象类型

QtQuick导入提供的所有对象类型都基于Item类型,该类型本身派生自QtObject。在导入QtQuick时,Qt QML模块提供的QML对象类型(如QtObject和Component)也可用。

CanvasProvides a 2D canvas item enabling drawing via JavaScript
CanvasGradientProvides an opaque CanvasGradient interface
CanvasImageDataContains image pixel data in RGBA order
CanvasPixelArrayProvides ordered and indexed access to the components of each pixel in image data
Context2DProvides 2D context for shapes on a Canvas item
AccessibleEnables accessibility of QML items
AnimatedImagePlays animations stored as a series of images
AnimatedSpriteDraws a sprite animation
BorderImagePaints a border based on an image
DragFor specifying drag and drop events for moved Items
DragEventProvides information about a drag event
DropAreaFor specifying drag and drop handling in an area
KeyEventProvides information about a key event
MouseEventProvides information about a mouse event
WheelEventProvides information about a mouse wheel event
FlickableProvides a surface that can be "flicked"
FlipableProvides a surface that can be flipped
FocusScopeExplicitly creates a focus scope
GraphicsInfoProvides information about the used Qt Quick backend
GridViewFor specifying a grid view of items provided by a model
ImageDisplays an image
EnterKeyProvides a property to manipulate the appearance of Enter key on an on-screen keyboard
ItemA basic visual QML type
KeyNavigationSupports key navigation by arrow keys
KeysProvides key handling to Items
LayoutMirroringProperty used to mirror layout behavior
TransformFor specifying advanced transformations on Items
AnchorAnimationAnimates changes in anchor values
ParentAnimationAnimates changes in parent values
PathAnimationAnimates an item along a path
ItemGrabResultContains the results from a call to Item::grabToImage()
ViewTransitionSpecifies items under transition in a view
ListViewProvides a list view of items provided by a model
LoaderAllows dynamic loading of a subtree from a URL or Component
MouseAreaEnables simple mouse handling
GestureEventParameter given with the gestureStarted signal
MultiPointTouchAreaEnables handling of multiple touch points
TouchPointDescribes a touch point in a MultiPointTouchArea
PathViewLays out model-provided items on a path
PinchAreaEnables simple pinch gesture handling
PinchEventFor specifying information about a pinch event
ColumnPositions its children in a column
FlowPositions its children side by side, wrapping as necessary
GridPositions its children in grid formation
PositionerProvides attached properties that contain details on where an item exists in a positioner
RowPositions its children in a row
GradientDefines a gradient fill
GradientStopDefines the color at a position in a Gradient
RectanglePaints a filled rectangle with an optional border
RepeaterInstantiates a number of Item-based components using a provided model
ShaderEffectApplies custom shaders to a rectangle
BorderImageMeshDefines a mesh with vertices arranged like those of a BorderImage
GridMeshDefines a mesh with vertices arranged in a grid
ShaderEffectSourceRenders a Qt Quick item into a texture and displays it
SpriteSpecifies sprite animations
SpriteSequenceDraws a sprite animation
AnchorChangesSpecifies how to change the anchors of an item in a state
ParentChangeSpecifies how to reparent an Item in a state change
TextSpecifies how to add formatted text to a scene
TextEditDisplays multiple lines of editable formatted text
TextInputDisplays an editable line of text
Matrix4x4Provides a way to apply a 4x4 tranformation matrix to an Item
RotationProvides a way to rotate an Item
ScaleProvides a way to scale an Item
TranslateProvides a way to move an Item without changing its x or y properties
AnimationIs the base of all QML animations
ColorAnimationAnimates changes in color values
NumberAnimationAnimates changes in qreal-type values
ParallelAnimationEnables animations to be run in parallel
PauseAnimationProvides a pause for an animation
PropertyActionSpecifies immediate property changes during animation
PropertyAnimationAnimates changes in property values
RotationAnimationAnimates changes in rotation values
ScriptActionDefines scripts to be run during an animation
SequentialAnimationAllows animations to be run sequentially
Vector3dAnimationAnimates changes in QVector3d values
AnimationControllerEnables manual control of animations
AnimatorIs the base of all QML animators
OpacityAnimatorType animates the opacity of an Item
RotationAnimatorType animates the rotation of an Item
ScaleAnimatorType animates the scale factor of an Item
UniformAnimatorType animates a uniform of a ShaderEffect
XAnimatorType animates the x position of an Item
YAnimatorType animates the y position of an Item
BehaviorDefines a default animation for a property change
FontLoaderAllows fonts to be loaded by name or URL
FontMetricsProvides metrics for a given font
PathDefines a path for use by PathView
PathArcDefines an arc with the given radius
PathAttributeSpecifies how to set an attribute at a given position in a Path
PathCubicDefines a cubic Bezier curve with two control points
PathCurveDefines a point on a Catmull-Rom curve
PathElementThe base path type
PathLineDefines a straight line
PathPercentManipulates the way a path is interpreted
PathQuadDefines a quadratic Bezier curve with a control point
PathSvgDefines a path using an SVG path data string
PathInterpolatorSpecifies how to manually animate along a path
PropertyChangesDescribes new property bindings or values for a state
ShortcutProvides keyboard shortcuts
SmoothedAnimationAllows a property to smoothly track a value
SpringAnimationAllows a property to track a value in a spring-like motion
StateDefines configurations of objects and properties
StateChangeScriptSpecifies how to run a script in a state
StateGroupProvides built-in state support for non-Item types
SystemPaletteProvides access to the Qt palettes
TextMetricsProvides metrics for a given font and text
TransitionDefines animated transitions that occur on state changes
DoubleValidatorDefines a validator for non-integer numbers
IntValidatorDefines a validator for integer values
RegExpValidatorProvides a string validator

 类似资料: