NodeInstantiator QML Type

Dynamically creates nodes. 更多...

import 语句: import Qt3D.Core 2.0
Since: Qt 5.5

特性

信号

方法

详细描述

A NodeInstantiator can be used to control the dynamic creation of nodes, or to dynamically create multiple objects from a template.

The NodeInstantiator element will manage the objects it creates. Those objects are parented to the Instantiator and can also be deleted by the NodeInstantiator NodeInstantiator 's properties change. Nodes can also be destroyed dynamically through other means, and the NodeInstantiator will not recreate them unless the properties of the NodeInstantiator change.

特性文档编制

active : bool

When active is true , and the delegate component is ready, the Instantiator will create objects according to the model. When active is false , no objects will be created and any previously created objects will be destroyed.

默认为 true .

asynchronous : bool

When asynchronous is true the Instantiator will attempt to create objects asynchronously. This means that objects may not be available immediately, even if active is set to true.

可以使用 objectAdded signal to respond to items being created.

默认为 false .

[read-only] count : int

The number of objects the Instantiator is currently managing.

[default] delegate : QtQml::Component

The component used to create all objects.

Note that an extra variable, index, will be available inside instances of the delegate. This variable refers to the index of the instance inside the Instantiator, and can be used to obtain the object through the itemAt method of the Instantiator.

If this property is changed, all instances using the old delegate will be destroyed and new instances will be created using the new delegate.

model : variant

This property can be set to any of the supported data models :

  • A number that indicates the number of delegates to be created by the repeater
  • A model (for example, a ListModel item or a QAbstractItemModel subclass)
  • A string list
  • An object list

The type of model affects the properties that are exposed to the delegate .

Default value is 1, which creates a single delegate instance.

另请参阅 数据模型 .

[read-only] 对象 : QtQml::QtObject

This is a reference to the first created object, intended as a convenience for the case where only one object has been created.


信号文档编制

void objectAdded ( int index , QtObject object )

This signal is emitted when a node is added to the NodeInstantiator index parameter holds the index which the node has been given, and the object parameter holds the Node that has been added.

相应处理程序是 onNodeAdded .

void objectRemoved ( int index , QtObject object )

This signal is emitted when an object is removed from the Instantiator. The index parameter holds the index which the object had been given, and the object parameter holds the QtObject that has been removed.

Do not keep a reference to object if it was created by this Instantiator, as in these cases it will be deleted shortly after the signal is handled.

相应处理程序是 onObjectRemoved .


方法文档编制

QtQml::QtObject objectAt ( int index )

Returns a reference to the object with the given index .