QDesignerPropertySheetExtension Class
QDesignerPropertySheetExtension 클래스를 사용하면 Qt Designer 의 속성 편집기에 표시되는 위젯의 속성을 조작할 수 있습니다. 더 보기...
| 헤더: | #include <QDesignerPropertySheetExtension> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Designer) target_link_libraries(mytarget PRIVATE Qt6::Designer) |
| qmake: | QT += designer |
공개 함수
| QDesignerPropertySheetExtension() | |
| QDesignerPropertySheetExtension(const QDesignerPropertySheetExtension &) | |
| QDesignerPropertySheetExtension(QDesignerPropertySheetExtension &&) | |
| virtual | ~QDesignerPropertySheetExtension() |
| virtual int | count() const = 0 |
| virtual bool | hasReset(int index) const = 0 |
| virtual int | indexOf(const QString &name) const = 0 |
| virtual bool | isAttribute(int index) const = 0 |
| virtual bool | isChanged(int index) const = 0 |
| virtual bool | isEnabled(int index) const = 0 |
| virtual bool | isVisible(int index) const = 0 |
| virtual QVariant | property(int index) const = 0 |
| virtual QString | propertyGroup(int index) const = 0 |
| virtual QString | propertyName(int index) const = 0 |
| virtual bool | reset(int index) = 0 |
| virtual void | setAttribute(int index, bool attribute) = 0 |
| virtual void | setChanged(int index, bool changed) = 0 |
| virtual void | setProperty(int index, const QVariant &value) = 0 |
| virtual void | setPropertyGroup(int index, const QString &group) = 0 |
| virtual void | setVisible(int index, bool visible) = 0 |
| QDesignerPropertySheetExtension & | operator=(QDesignerPropertySheetExtension &&) |
| QDesignerPropertySheetExtension & | operator=(const QDesignerPropertySheetExtension &) |
상세 설명
QDesignerPropertySheetExtension은 일반적으로 위젯의 속성을 조회하고 속성 편집기에서 속성의 표시 방식을 조작하는 데 사용되는 일련의 함수들을 제공합니다. 예를 들어:
QDesignerPropertySheetExtension *propertySheet = nullptr;
QExtensionManager manager = formEditor->extensionManager();
propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
int index = propertySheet->indexOf(u"margin"_s);
propertySheet->setProperty(index, 10);
propertySheet->setChanged(index, true);
delete propertySheet;QDesignerPropertySheetExtension::setProperty() 함수를 사용하여 속성의 값을 변경할 경우, 실행 취소 스택이 업데이트되지 않는다는 점에 유의하십시오. 실행 취소 스택을 통해 속성 값을 되돌릴 수 있도록 하려면, 대신 QDesignerFormWindowCursorInterface::setProperty() 함수나 그 버디 함수인 setWidgetProperty()를 사용해야 합니다.
QDesignerCustomWidgetInterface::initialize사용자 정의 위젯 플러그인을 구현할 때, ` Qt Widgets Designer()` 함수의 매개변수를 통해 ` `의 현재 ` QDesignerFormEditorInterface ` 객체(위 예시에서는 `formEditor `)에 대한 포인터가 제공됩니다.
프로퍼티 시트나 기타 확장 기능은 qt_extension() 함수를 사용하여 Qt Widgets Designer 의 확장 관리자를 쿼리함으로써 가져올 수 있습니다. 확장을 해제하려면 해당 포인터를 삭제하기만 하면 됩니다.
모든 위젯에는 기본 속성 시트가 있으며, 이 시트는 Qt Widgets Designer 의 속성 편집기에 위젯의 속성(즉, Q_PROPERTY() 매크로로 정의된 속성)을 채워줍니다. 하지만 QDesignerPropertySheetExtension은 사용자 정의 속성 시트 확장을 생성하기 위한 인터페이스도 제공합니다.
다음과 같은 제한 사항을 유의하십시오:
- Qt Widgets Designer Qt Widgets Designer 는 QDesignerPropertySheetExtension을 사용하여 속성 편집기를 채웁니다. 작업 공간에서 위젯이 선택될 때마다 는 해당 위젯의 속성 시트 확장을 조회합니다. 선택한 위젯에 구현된 속성 시트 확장이 있는 경우, 이 확장이 기본 속성 시트를 재정의합니다.
- 일부 속성에 대해 속성 시트가 사용하는 데이터 유형은 일반 Qt 데이터 유형 대신 추가 정보를 포함하는 불투명한 사용자 정의 QVariant 유형입니다. 예를 들어, 열거형, 플래그, 아이콘, 픽스맵 및 문자열이 이에 해당합니다.
- Qt Widgets Designer's 속성 편집기는 ` Q_DECLARE_METATYPE()`로 선언된 사용자 정의 유형에 대한 ` Q_PROPERTY ` 유형을 처리하는 구현을 가지고 있지 않습니다.
속성 시트 확장 기능을 만들려면, 확장 클래스가 ` QObject `와 `QDesignerPropertySheetExtension`을 모두 상속받아야 합니다. 그런 다음, 인터페이스를 구현하고 있으므로 ` Q_INTERFACES()` 매크로를 사용하여 메타 객체 시스템에 해당 인터페이스가 알려지도록 해야 합니다:
class MyPropertySheetExtension : public QObject,
public QDesignerPropertySheetExtension
{
Q_OBJECT
Q_INTERFACES(QDesignerPropertySheetExtension)
public:
...
}이를 통해 Qt Widgets Designer 은 QObject 포인터만 사용하여 qobject_cast()을 통해 지원되는 인터페이스를 조회할 수 있습니다.
Qt Widgets Designer 에서는 확장 기능이 필요할 때까지 생성되지 않습니다. 따라서 속성 시트 확장 기능을 구현할 때는 QExtensionFactory, 즉 확장 기능의 인스턴스를 생성할 수 있는 클래스를 만들고, Qt Widgets Designer 의 extension manager 를 사용하여 이를 등록해야 합니다.
프로퍼티 시트 확장 기능이 요청되면, Qt Widgets Designer 의 extension manager 는 등록된 모든 팩토리를 순차적으로 검사하며, 각 팩토리에 대해 QExtensionFactory::createExtension()를 호출하여 선택된 위젯에 대한 프로퍼티 시트 확장 기능을 생성할 수 있는 첫 번째 팩토리가 발견될 때까지 이 과정을 반복합니다. 이 팩토리는 이후 확장 기능의 인스턴스를 생성합니다. 해당 팩토리를 찾을 수 없는 경우, Qt Widgets Designer 는 기본 프로퍼티 시트를 사용합니다.
Qt Widgets Designer 에는 QDesignerContainerExtension, QDesignerMemberSheetExtension, QDesignerPropertySheetExtension 및 QDesignerTaskMenuExtension 등 네 가지 유형의 확장 기능이 있습니다. Qt Designer 의 동작은 요청된 확장 기능이 다중 페이지 컨테이너, 멤버 시트, 속성 시트 또는 작업 메뉴와 연관되어 있는지 여부에 관계없이 동일합니다.
QExtensionFactory 클래스는 표준 확장 팩토리를 제공하며, 사용자 정의 확장 팩토리를 위한 인터페이스로도 사용할 수 있습니다. 새로운 QExtensionFactory 를 생성하고 QExtensionFactory::createExtension() 함수를 재구현할 수 있습니다. 예를 들어:
QObject *ANewExtensionFactory::createExtension(QObject *object,
const QString &iid, QObject *parent) const
{
if (iid != Q_TYPEID(QDesignerPropertySheetExtension))
return 0;
if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
(object))
return new MyPropertySheetExtension(widget, parent);
return 0;
}또는 기존 팩토리를 사용하여 QExtensionFactory::createExtension() 함수를 확장함으로써, 해당 팩토리가 속성 시트 확장도 생성할 수 있도록 할 수 있습니다. 예를 들어:
QObject *AGeneralExtensionFactory::createExtension(QObject *object,
const QString &iid, QObject *parent) const
{
MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
return new MyTaskMenuExtension(widget, parent);
} else if (widget && (iid == Q_TYPEID(QDesignerPropertySheetExtension))) {
return new MyPropertySheetExtension(widget, parent);
} else {
return 0;
}
}확장 클래스를 사용한 전체 예제는 ‘작업 메뉴 확장(Task Menu Extension)’ 예제를 참조하십시오. 이 예제는 Qt Designer 용 사용자 정의 위젯 플러그인을 만드는 방법과, QDesignerTaskMenuExtension 클래스를 사용하여 Qt Widgets Designer 의 작업 메뉴에 사용자 정의 항목을 추가하는 방법을 보여줍니다.
QDesignerDynamicPropertySheetExtension, QExtensionFactory, QExtensionManager 및 사용자 정의 위젯 확장 만들기문서도 참조하십시오 .
멤버 함수 설명서
[constexpr noexcept default] QDesignerPropertySheetExtension::QDesignerPropertySheetExtension()
QDesignerPropertySheetExtension 의 인스턴스를 기본 생성자로 생성합니다.
[delete] QDesignerPropertySheetExtension::QDesignerPropertySheetExtension(const QDesignerPropertySheetExtension &)
QDesignerPropertySheetExtension 의 인스턴스를 복사 생성합니다. 이 함수는 삭제되었습니다.
[delete] QDesignerPropertySheetExtension::QDesignerPropertySheetExtension(QDesignerPropertySheetExtension &&)
QDesignerPropertySheetExtension 의 인스턴스를 move-construct로 생성합니다. 이 함수는 삭제되었습니다.
[virtual constexpr noexcept default] QDesignerPropertySheetExtension::~QDesignerPropertySheetExtension()
속성 시트 확장 기능을 제거합니다.
[pure virtual] int QDesignerPropertySheetExtension::count() const
선택된 위젯의 속성 개수를 반환합니다.
[pure virtual] bool QDesignerPropertySheetExtension::hasReset(int index) const
지정된 index 에 있는 속성이 Qt Widgets Designer 의 속성 편집기에 재설정 버튼이 있는 경우 true를 반환하고, 그렇지 않은 경우 false를 반환합니다.
[pure virtual] int QDesignerPropertySheetExtension::indexOf(const QString &name) const
지정된 속성 name 의 인덱스를 반환합니다.
propertyName()도 참조하십시오 .
[pure virtual] bool QDesignerPropertySheetExtension::isAttribute(int index) const
지정된 index 에 있는 속성이 UI 파일에서 제외될 속성(attribute)인 경우 true를 반환하고, 그렇지 않으면 false를 반환합니다.
indexOf() 및 setAttribute()도 참조하십시오 .
[pure virtual] bool QDesignerPropertySheetExtension::isChanged(int index) const
지정된 index 에서 속성의 값이 해당 속성의 기본값과 다를 경우 true를 반환하고, 그렇지 않으면 false를 반환합니다.
indexOf(), setChanged(), reset()도 참조하십시오 .
[pure virtual] bool QDesignerPropertySheetExtension::isEnabled(int index) const
지정된 index 에 있는 속성이 Qt Widgets Designer 의 속성 편집기에서 활성화되어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
indexOf()도 참조하십시오 .
[pure virtual] bool QDesignerPropertySheetExtension::isVisible(int index) const
지정된 index 에 있는 속성이 Qt Widgets Designer 의 속성 편집기에서 표시되는 경우 true를 반환하고, 그렇지 않은 경우 false를 반환합니다.
indexOf() 및 setVisible()도 참조하십시오 .
[pure virtual] QVariant QDesignerPropertySheetExtension::property(int index) const
지정된 index 에 있는 속성의 값을 반환합니다.
indexOf(), setProperty(), propertyGroup()도 참조하십시오 .
[pure virtual] QString QDesignerPropertySheetExtension::propertyGroup(int index) const
지정된 index 에 해당하는 속성의 속성 그룹을 반환합니다.
Qt Widgets Designer's 속성 편집기는 속성 그룹, 즉 관련 속성들로 구성된 섹션을 지원합니다. setPropertyGroup() 함수를 사용하여 속성을 그룹과 연결할 수 있습니다. 모든 속성의 기본 그룹은 해당 속성을 정의하는 클래스의 이름입니다. 예를 들어, QObject::objectName 속성은 QObject 속성 그룹 내에 나타납니다.
indexOf() 및 setPropertyGroup()도 참조하십시오 .
[pure virtual] QString QDesignerPropertySheetExtension::propertyName(int index) const
지정된 index 위치에 있는 속성의 이름을 반환합니다.
indexOf()도 참조하십시오 .
[pure virtual] bool QDesignerPropertySheetExtension::reset(int index)
지정된 index 의 속성 값을 기본값으로 재설정합니다. 기본값을 찾을 수 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
indexOf(), hasReset(), isChanged()도 참조하십시오 .
[pure virtual] void QDesignerPropertySheetExtension::setAttribute(int index, bool attribute)
attribute 가 true인 경우, 지정된 index 에 있는 속성은 UI 파일에서 제외될 속성으로 처리되며, 그렇지 않은 경우 포함됩니다.
indexOf() 및 isAttribute()도 참조하십시오 .
[pure virtual] void QDesignerPropertySheetExtension::setChanged(int index, bool changed)
changed 매개변수에 따라, 지정된 index 에 있는 속성이 기본값과 다른지 여부를 설정합니다.
indexOf() 및 isChanged()도 참조하십시오 .
[pure virtual] void QDesignerPropertySheetExtension::setProperty(int index, const QVariant &value)
지정된 index 값으로 속성의 value 을 설정합니다.
경고: 이 함수를 사용하여 속성의 값을변경하면 실행 취소 스택이 업데이트되지 않습니다. 실행 취소 스택을 사용하여 속성의 값을 되돌릴 수 있도록 하려면, 대신 QDesignerFormWindowCursorInterface::setProperty() 함수나 그 버디 함수인 setWidgetProperty()을 사용해야 합니다.
indexOf(), property(), propertyGroup()도 참조하십시오 .
[pure virtual] void QDesignerPropertySheetExtension::setPropertyGroup(int index, const QString &group)
지정된 index 에 있는 속성의 속성 그룹을 group 로 설정합니다.
속성을 그룹에 연결하면 속성 편집기에서 해당 그룹의 섹션 내에 속성이 표시됩니다. 모든 속성의 기본 속성 그룹은 해당 속성을 정의하는 클래스의 이름입니다. 예를 들어, QObject::objectName 속성은 QObject 속성 그룹 내에 표시됩니다.
indexOf(), property(), propertyGroup()도 참조하십시오 .
[pure virtual] void QDesignerPropertySheetExtension::setVisible(int index, bool visible)
visible 의 값이 true인 경우, 지정된 index 에 있는 속성이 Qt Widgets Designer 의 속성 편집기에 표시되며, 그렇지 않은 경우 해당 속성은 숨겨집니다.
indexOf() 및 isVisible()도 참조하십시오 .
[delete] QDesignerPropertySheetExtension &QDesignerPropertySheetExtension::operator=(QDesignerPropertySheetExtension &&)
other 를 이 QDesignerPropertySheetExtension 인스턴스에 할당합니다. 이 함수는 삭제됩니다.
[delete] QDesignerPropertySheetExtension &QDesignerPropertySheetExtension::operator=(const QDesignerPropertySheetExtension &)
other 를 이 QDesignerPropertySheetExtension 인스턴스에 복사-할당합니다. 이 함수는 삭제되었습니다.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.