QDesignerMemberSheetExtension Class
QDesignerMemberSheetExtension クラスを使用すると、Qt Widgets Designer のシグナルとスロットの編集モードを使用して接続を構成するときに表示されるウィジェットのメンバ関数を操作できます。詳細...
| ヘッダー | #include <QDesignerMemberSheetExtension> |
| CMake.MemberSheetExtensionクラス | find_package(Qt6 REQUIRED COMPONENTS Designer)target_link_libraries(mytarget PRIVATE Qt6::Designer) |
| qmake: | QT += designer |
パブリック関数
| virtual | ~QDesignerMemberSheetExtension() |
| virtual int | count() const = 0 |
| virtual QString | declaredInClass(int index) const = 0 |
| virtual int | indexOf(const QString &name) const = 0 |
| virtual bool | inheritedFromWidget(int index) const = 0 |
| virtual bool | isSignal(int index) const = 0 |
| virtual bool | isSlot(int index) const = 0 |
| virtual bool | isVisible(int index) const = 0 |
| virtual QString | memberGroup(int index) const = 0 |
| virtual QString | memberName(int index) const = 0 |
| virtual QList<QByteArray> | parameterNames(int index) const = 0 |
| virtual QList<QByteArray> | parameterTypes(int index) const = 0 |
| virtual void | setMemberGroup(int index, const QString &group) = 0 |
| virtual void | setVisible(int index, bool visible) = 0 |
| virtual QString | signature(int index) const = 0 |
詳細説明
QDesignerMemberSheetExtensionは、通常、ウィジェットのメンバ関数を照会し、Qt Widgets Designer'のシグナルとスロットの編集モードでメンバ関数の外観を操作するために使用される関数のコレクションです。例えば
QDesignerMemberSheetExtension *memberSheet = nullptr; QExtensionManager manager = formEditor->extensionManager(); memberSheet = qt_extension<QDesignerMemberSheetExtension*>(manager, widget); int index = memberSheet->indexOf(setEchoMode); memberSheet->setVisible(index, false); delete memberSheet;
カスタムウィジェットプラグインを実装する場合、Qt Widgets Designer'の現在のQDesignerFormEditorInterface オブジェクト ( 上の例ではformEditor ) へのポインタは、QDesignerCustomWidgetInterface::initialize() 関数のパラメータで提供されます。
メンバ・シート(およびその他の拡張機能)は、qt_extension() 関数を使用してQt Widgets Designer の拡張機能マネージャに問い合わせることで取得できます。拡張機能を解放したい場合は、ポインタを削除するだけです。
すべてのウィジェットには、Qt Widgets Designer'のシグナルとスロットの編集モードでウィジェットのメンバ関数で使用されるデフォルトのメンバシートがあります。しかし、QDesignerMemberSheetExtension は、カスタム・メンバー・シート拡張を作成するためのインターフェイスも提供します。
警告: Qt Widgets Designer は QDesignerMemberSheetExtension を使用して、シグナルとスロットの編集モードを容易にします。2つのウィジェット間の接続が要求されるたびに、Qt Widgets Designer はウィジェットのメンバシート拡張を問い合わせます。ウィジェットにメンバシート拡張が実装されている場合、この拡張はデフォルトのメンバシートを上書きします。
メンバシート拡張機能を作成するには、QObject と QDesignerMemberSheetExtension の両方を継承する必要があります。それから、インターフェイスを実装しているので、Q_INTERFACES() マクロを使用して、メタ・オブジェクト・システムに確実に知らせる必要があります:
class MyMemberSheetExtension : public QObject, public QDesignerMemberSheetExtension { Q_OBJECT Q_INTERFACES(QDesignerMemberSheetExtension) public: ... }
これにより、Qt Widgets Designer は、qobject_cast() を使用して、QObject ポインタのみを使用して、サポートされているインターフェイスを問い合わせることができます。
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 の 4 種類の拡張機能があります。Qt Widgets Designer の動作は、要求された拡張機能がマルチ・ページ・コンテナ、メンバー・シート、プロパティ・シート、タスク・メニューのいずれに関連付けられていても同じです。
QExtensionFactory クラスは標準拡張ファクトリを提供し、カスタム拡張ファクトリのインターフェイスとしても使用できます。新しいQExtensionFactory を作成し、QExtensionFactory::createExtension() 関数を再実装することができます。例えば
QObject *ANewExtensionFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const { if (iid != Q_TYPEID(QDesignerMemberSheetExtension)) return 0; if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*> (object)) return new MyMemberSheetExtension(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(QDesignerMemberSheetExtension))) { return new MyMemberSheetExtension(widget, parent); } else { return 0; } }
拡張クラスを使用した完全な例については、タスクメニュー拡張の例を参照してください。この例では、Qt Designer のカスタムウィジェットプラグインを作成する方法と、QDesignerTaskMenuExtension クラスを使用してQt Widgets Designer のタスクメニューにカスタム項目を追加する方法を示します。
QExtensionFactory 、QExtensionManager 、および「カスタム ウィジェット拡張機能の作成」も参照して ください。
メンバ関数のドキュメント
[virtual constexpr noexcept] QDesignerMemberSheetExtension::~QDesignerMemberSheetExtension()
メンバーシート拡張を破棄する。
[pure virtual] int QDesignerMemberSheetExtension::count() const
拡張機能のメンバ関数の数を返す。
[pure virtual] QString QDesignerMemberSheetExtension::declaredInClass(int index) const
与えられたindex を持つメンバ関数が宣言されているクラスの名前を返します。
indexOf()も参照 。
[pure virtual] int QDesignerMemberSheetExtension::indexOf(const QString &name) const
与えられたname で指定されたメンバ関数のインデックスを返します。
memberName()も参照 。
[pure virtual] bool QDesignerMemberSheetExtension::inheritedFromWidget(int index) const
指定されたindex のメンバ関数がQWidget から継承されている場合は true を返し、そうでない場合は false を返します。
indexOf()も参照してください 。
[pure virtual] bool QDesignerMemberSheetExtension::isSignal(int index) const
与えられたindex を持つメンバ関数がシグナルであれば真を、そうでなければ偽を返す。
indexOf()も参照 。
[pure virtual] bool QDesignerMemberSheetExtension::isSlot(int index) const
与えられたindex を持つメンバ関数がスロットであれば真を、そうでなければ偽を返します。
indexOf()も参照してください 。
[pure virtual] bool QDesignerMemberSheetExtension::isVisible(int index) const
与えられたindex を持つメンバ関数がQt Widgets Designer のシグナル・スロット・エディタに表示されている場合は真を、そうでない場合は偽を返します。
indexOf() およびsetVisible()も参照してください 。
[pure virtual] QString QDesignerMemberSheetExtension::memberGroup(int index) const
与えられたindex を持つ関数に指定されたメンバ・グループの名前を返す。
indexOf() およびsetMemberGroup()も参照のこと 。
[pure virtual] QString QDesignerMemberSheetExtension::memberName(int index) const
与えられたindex を持つメンバ関数の名前を返します。
indexOf()も参照 。
[pure virtual] QList<QByteArray> QDesignerMemberSheetExtension::parameterNames(int index) const
与えられたindex を持つメンバ関数のパラメータ名をQByteArray リストとして返します。
indexOf() およびparameterTypes()も参照 。
[pure virtual] QList<QByteArray> QDesignerMemberSheetExtension::parameterTypes(int index) const
与えられたindex を持つメンバ関数のパラメータ型をQByteArray リストとして返します。
indexOf() およびparameterNames()も参照 。
[pure virtual] void QDesignerMemberSheetExtension::setMemberGroup(int index, const QString &group)
指定されたindex を持つメンバ関数のメンバ・グループをgroup に設定します。
indexOf() およびmemberGroup()も参照 。
[pure virtual] void QDesignerMemberSheetExtension::setVisible(int index, bool visible)
visible が真の場合、与えられたindex を持つメンバ関数は、Qt Widgets Designer のシグナルとスロットの編集モードで表示される。
indexOf() およびisVisible()も参照のこと 。
[pure virtual] QString QDesignerMemberSheetExtension::signature(int index) const
与えられたindex を持つメンバ関数のシグネチャを返します。
indexOf()も参照 。
© 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.