Version:

O3DEUI 反射属性编辑器

反射的属性编辑器 会自动为使用编辑上下文反映的用户可编辑属性布置控件。它经常用作内容小部件来填充 card组件。

component reflected property editor in card

有关反射和编辑上下文的更多信息,请参阅 O3DE 用户指南中的 反射组件以进行序列化和编辑

卡片中的反射属性编辑器

以下代码演示如何将简单的 反射属性编辑器 添加到 中,如本主题开头的图片中所示。

示例

#include <AzToolsFramework/UI/PropertyEditor/ReflectedPropertyEditor.hxx>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzQtComponents/Components/Widgets/Card.h>

// Create a card widget and set its title and header icon.
AzQtComponents::Card* card = new AzQtComponents::Card(parent);
card->setTitle(QStringLiteral("Card"));
card->header()->setIcon(QIcon(QStringLiteral(":/Gallery/Grid-small.svg")));

// Create a reflected property editor.
auto cardPropertyEditor = aznew AzToolsFramework::ReflectedPropertyEditor(card);

// Add the reflected property editor to the card as a content widget.
card->setContentWidget(cardPropertyEditor);

C++ API参考

有关 card API 的详细信息,请参阅 O3DE UI 扩展 C++ API 参考 中的以下主题:

相关链接

有关 reflected property editor 组件的其他信息,请参阅以下主题: