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() override |
| 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 のプロパティエディタへのインターフェースを取得できます。QDesignerCustomWidgetInterface::initialize() 関数のパラメータには、Qt Widgets Designer の現在のQDesignerFormEditorInterface オブジェクト(上記の例ではformEditor )へのポインタが渡されます。カスタムウィジェットプラグインを実装する際は、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 を使用して、プロパティエディタインターフェースを構築します。
[override 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)
このシグナルは、プロパティエディタでプロパティが変更されるたびに発火します。変更されたプロパティとその新しい値は、それぞれ `name ` および `value ` で指定されます。
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 が true の場合、プロパティエディタは書き込み保護状態になります。そうでない場合は、書き込み保護が解除されます。
isReadOnly()も参照してください 。
© 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.