In questa pagina

QDesignerPropertyEditorInterface Class

La classe `QDesignerPropertyEditorInterface` consente di interrogare e modificare lo stato corrente dell'editor delle proprietà di ` Qt Widgets Designer`. Per saperne di più...

Intestazione: #include <QDesignerPropertyEditorInterface>
CMake: find_package(Qt6 REQUIRED COMPONENTS Designer)
target_link_libraries(mytarget PRIVATE Qt6::Designer)
qmake: QT += designer
Eredita da: QWidget

Funzioni pubbliche

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

Slot pubblici

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

Segnali

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

Descrizione dettagliata

QDesignerPropertyEditorInterface contiene una raccolta di funzioni che vengono solitamente utilizzate per interrogare l'editor delle proprietà riguardo al suo stato attuale, oltre a diversi slot che ne modificano lo stato. L'interfaccia fornisce inoltre un segnale, propertyChanged(), che viene emesso ogni volta che una proprietà viene modificata nell'editor delle proprietà. Gli argomenti del segnale sono la proprietà che è stata modificata e il suo nuovo valore.

Ad esempio, quando si implementa un plugin per widget personalizzato, è possibile collegare il segnale a uno slot personalizzato:

        auto *propertyEditor = formEditor->propertyEditor();

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

In questo modo, lo slot personalizzato può verificare se il nuovo valore rientra nell’intervallo desiderato quando una determinata proprietà, appartenente a un particolare widget, viene modificata:

        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)
                {...}
        }

La classe `QDesignerPropertyEditorInterface` non è pensata per essere istanziata direttamente. È possibile recuperare un'interfaccia per l'editor delle proprietà di ` Qt Widgets Designer` utilizzando la funzione ` QDesignerFormEditorInterface::propertyEditor()`. Un puntatore all'oggetto ` QDesignerFormEditorInterface ` corrente di ` Qt Widgets Designer` (`formEditor ` negli esempi sopra riportati) viene fornito dal parametro della funzione ` QDesignerCustomWidgetInterface::initialize()`. Quando si implementa un plugin per widget personalizzato, è necessario creare una sottoclasse di ` QDesignerCustomWidgetInterface ` per esporre il proprio plugin a ` Qt Widgets Designer`.

Le funzioni che accedono all'editor delle proprietà sono la funzione core(), che consente di recuperare un'interfaccia per l'editor dei moduli, la funzione currentPropertyName(), che restituisce il nome della proprietà attualmente selezionata nell'editor delle proprietà, la funzione object(), che restituisce l'oggetto attualmente selezionato nell'area di lavoro di Qt Widgets Designer, e la funzione isReadOnly(), che restituisce true se l'editor delle proprietà è protetto in scrittura (altrimenti "false").

Gli slot che gestiscono lo stato dell’editor delle proprietà sono lo slot setObject() che è possibile utilizzare per modificare l’oggetto attualmente selezionato nell’area di lavoro di Qt Widgets Designer, lo slot setPropertyValue() che modifica il valore di una determinata proprietà e lo slot setReadOnly() che controlla la protezione in scrittura dell’editor delle proprietà.

Vedi anche QDesignerFormEditorInterface.

Documentazione delle funzioni membro

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

Crea un'interfaccia per l'editor delle proprietà con l'parent specificato e la finestra flags specificata.

[override virtual noexcept] QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface()

Chiude l'interfaccia dell'editor delle proprietà.

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

Restituisce un puntatore all'oggetto ` QDesignerFormEditorInterface ` corrente di ` Qt Widgets Designer`.

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

Restituisce il nome della proprietà attualmente selezionata nell'editor delle proprietà.

Vedi anche setPropertyValue().

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

Restituisce true se l'editor delle proprietà è protetto in scrittura; altrimenti restituisce false.

Vedi anche setReadOnly().

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

Restituisce l'oggetto attualmente selezionato nell'area di lavoro di Qt Widgets Designer.

Vedi anche setObject().

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

Questo segnale viene emesso ogni volta che una proprietà viene modificata nell'editor delle proprietà. La proprietà modificata e il suo nuovo valore sono specificati rispettivamente da name e value.

Vedi anche setPropertyValue().

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

Modifica l'oggetto attualmente selezionato nell'area di lavoro di Qt Widgets Designer, sostituendolo con object.

Vedi anche object().

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

Imposta il valore della proprietà specificata da ` name ` su ` value`.

Inoltre, la proprietà viene contrassegnata come changed nell'editor delle proprietà, ovvero il suo valore è diverso dal valore predefinito.

Vedi anche currentPropertyName() e propertyChanged().

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

Se readOnly è vero, l'editor delle proprietà viene protetto in scrittura; in caso contrario, la protezione in scrittura viene rimossa.

Vedi anche 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.