QDesignerPropertyEditorInterface Class

QDesignerPropertyEditorInterface クラスを使用すると、Qt Widgets Designer のプロパティエディタの現在の状態を照会および操作できます。詳細...

ヘッダー #include <QDesignerPropertyEditorInterface>
CMake: find_package(Qt6 REQUIRED COMPONENTS Designer)
target_link_libraries(mytarget PRIVATE Qt6::Designer)
qmake: QT += designer
継承: QWidget

パブリック関数

QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags = {})
virtual ~QDesignerPropertyEditorInterface()
virtual QDesignerFormEditorInterface *core() const
virtual QString currentPropertyName() const = 0
virtual bool isReadOnly() const = 0
virtual QObject *object() const = 0

パブリックスロット

virtual void setObject(QObject *object) = 0
virtual void setPropertyValue(const QString &name, const QVariant &value, bool changed = true) = 0
virtual void setReadOnly(bool readOnly) = 0

シグナル

void propertyChanged(const QString &name, const QVariant &value)

詳細説明

QDesignerPropertyEditorInterfaceには、プロパティ・エディタの現在の状態を問い合わせるために一般的に使用される関数のコレクションと、その状態を操作するいくつかのスロットが含まれています。また、このインターフェイスは、プロパティエディタ内でプロパティが変更されるたびに発行されるシグナルpropertyChanged ()を提供します。シグナルの引数は、変更されたプロパティとその新しい値です。

例えば、カスタムウィジェットプラグインを実装する場合、シグナルをカスタムスロットに接続することができます:

        auto *propertyEditor = formEditor->propertyEditor();

        connect(propertyEditor, &QDesignerPropertyEditorInterface::propertyChanged,
                this, &MyClass::checkProperty);

カスタムスロットは、特定のウィジェットに属する指定されたプロパティが変更されたときに、新しい値が必要な範囲内にあるかどうかをチェックすることができます:

        void checkProperty(const QString &property, const QVariant &value)
        {
            auto *propertyEditor = formEditor->propertyEditor();

            auto *object = propertyeditor->object();
            auto *widget = qobject_cast<MyCustomWidget *>(object);

            if (widget && property == aProperty && value != expectedValue)
                {...}
        }

QDesignerPropertyEditorInterfaceクラスは、直接インスタンス化することを意図していません。QDesignerFormEditorInterface::propertyEditor() 関数を使用して、Qt Widgets Designer のプロパティ・エディタへのインタフェースを取得できます。Qt Widgets Designerの現在のQDesignerFormEditorInterface オブジェクト(上記の例ではformEditor )へのポインタは、QDesignerCustomWidgetInterface::initialize ()関数のパラメータで提供されます。カスタム ウィジェット プラグインを実装する場合は、QDesignerCustomWidgetInterface をサブクラス化してプラグインをQt Widgets Designer に公開する必要があります。

プロパティ・エディタにアクセスする関数は、フォーム・エディタへのインターフェイスを取得するために使用できるcore() 関数、プロパティ・エディタで現在選択されているプロパティの名前を返すcurrentPropertyName() 関数、Qt Widgets Designer のワークスペースで現在選択されているオブジェクトを返すobject() 関数、およびプロパティ・エディタが書き込み保護されている場合に true を返すisReadOnly() 関数です(そうでない場合は false)。

プロパティ・エディタの状態を操作するスロットは、Qt Widgets Designer のワークスペースで現在選択されているオブジェクトを変更するために使用できるsetObject() スロット、指定されたプロパティの値を変更するsetPropertyValue() スロット、およびプロパティ・エディタの書き込み保護を制御するsetReadOnly() スロットです。

QDesignerFormEditorInterfaceも参照してください

メンバ関数ドキュメント

[explicit] QDesignerPropertyEditorInterface::QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags = {})

与えられたparent と指定されたウィンドウflags を持つプロパティエディタインターフェイスを構築します。

[virtual noexcept] QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface()

プロパティエディタインターフェースを破棄します。

[virtual] QDesignerFormEditorInterface *QDesignerPropertyEditorInterface::core() const

Qt Widgets Designer の現在のQDesignerFormEditorInterface オブジェクトへのポインタを返します。

[pure virtual] QString QDesignerPropertyEditorInterface::currentPropertyName() const

プロパティ・エディタで現在選択されているプロパティの名前を返します。

setPropertyValue()も参照してください

[pure virtual] bool QDesignerPropertyEditorInterface::isReadOnly() const

プロパティ・エディタが書き込み保護されている場合はtrueを返し、そうでない場合はfalseを返します。

setReadOnly()も参照してください

[pure virtual] QObject *QDesignerPropertyEditorInterface::object() const

Qt Widgets Designer のワークスペースで現在選択されているオブジェクトを返します。

setObject()も参照してください

[signal] void QDesignerPropertyEditorInterface::propertyChanged(const QString &name, const QVariant &value)

このシグナルは、プロパティエディタでプロパティが変更されるたびに発行される。変更されたプロパティとその新しい値は、それぞれnamevalue で指定されます。

setPropertyValue()も参照してください

[pure virtual slot] void QDesignerPropertyEditorInterface::setObject(QObject *object)

Qt Widgets Designer のワークスペースで現在選択されているオブジェクトをobject に変更します。

object()も参照してください

[pure virtual slot] void QDesignerPropertyEditorInterface::setPropertyValue(const QString &name, const QVariant &value, bool changed = true)

name で指定されたプロパティの値をvalue に設定します。

さらに、このプロパティは、プロパティ・エディタでchanged としてマークされます。

currentPropertyName() およびpropertyChanged()も参照してください

[pure virtual slot] void QDesignerPropertyEditorInterface::setReadOnly(bool readOnly)

readOnly が真の場合、プロパティ・エディタは書き込み保護されます。そうでない場合、書き込み保護は解除されます。

isReadOnly()も参照してください

© 2025 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.