In questa pagina

Qt3DRender::QParameter Class

class Qt3DRender::QParameter

Consente di memorizzare una coppia nome-valore. Ciò corrisponde a un’uniform dello shader. Maggiori informazioni...

Intestazione: #include <Qt3DRender/QParameter>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
In QML: Parameter
Eredita da: Qt3DCore::QNode
Stato: Obsoleto

Questa classe è deprecata. Si sconsiglia vivamente di utilizzarla nel nuovo codice.

Proprietà

Funzioni pubbliche

QParameter(Qt3DCore::QNode *parent = nullptr)
QParameter(const QString &name, Qt3DRender::QAbstractTexture *texture, Qt3DCore::QNode *parent = nullptr)
QParameter(const QString &name, const QVariant &value, Qt3DCore::QNode *parent = nullptr)
QString name() const
QVariant value() const

Slot pubblici

void setName(const QString &name)
void setValue(const QVariant &dv)

Segnali

void nameChanged(const QString &name)
void valueChanged(const QVariant &value)

Descrizione dettagliata

È possibile fare riferimento a un QParameter tramite un QRenderPass, QTechnique, QEffect, QMaterial, QTechniqueFilter, QRenderPassFilter. In fase di esecuzione, a seconda dello shader selezionato per una determinata fase del rendering, il valore contenuto in un QParameter verrà convertito e caricato se lo shader contiene un'uniform con un nome corrispondente a quello del QParameter.

QParameter *param = new QParameter();
param->setName(QStringLiteral("diffuseColor"));
param->setValue(QColor::fromRgbF(0.0f, 0.0f, 1.0f, 1.0f));

// Alternatively you can create and set a QParameter this way
QParameter *param2 = new QParameter(QStringLiteral("diffuseColor"), QColor::fromRgbF(0.0f, 0.0f, 1.0f, 1.0f));

// Such QParameters will work with the following GLSL uniform shader declarations
// uniform vec4 diffuseColor;
// uniform vec3 diffuseColor;
// uniform vec2 diffuseColor;
// uniform float diffuseColor;

Nota: occorre prestareattenzione per garantire che il valore racchiuso in un QParameter possa effettivamente essere convertito in ciò che l’uniform reale si aspetta. Assegnare un valore memorizzato come int laddove l’uniform dello shader sia di tipo float potrebbe causare comportamenti indefiniti.

Nota: quando l’uniform di destinazione è un array, il nome deve essere quello dell’uniform con [0] aggiunto alla fine.

Nota: il nodoQParameter non può essere disabilitato.

QParameter *param = new QParameter();
QVariantList values = QVariantList() << 0.0f << 1.0f << 2.0f << 3.0f << 4.0f << 883.0f << 1340.0f << 1584.0f;

param->setName(QStringLiteral("diffuseValues[0]"));
param->setValue(values);

// Matching GLSL shader uniform  declaration
// uniform float diffuseValues[8];

Per quanto riguarda il supporto delle texture, il valore di QParameter deve essere impostato sulla sottoclasse appropriata di QAbstractTexture che corrisponda al tipo di campionatore dell’uniform dello shader.

QTexture2D *texture = new QTexture2D();
...
QParameter *param = new QParameter();
param->setName(QStringLiteral("diffuseTexture"));
param->setValue(QVariant::fromValue(texture));

// Works with the following GLSL uniform shader declaration
// uniform sampler2D diffuseTexture

Vedi anche QAbstractTexture.

Documentazione delle proprietà

name : QString

Specifica il nome del parametro

Funzioni di accesso:

QString name() const
void setName(const QString &name)

Segnale di notifica:

void nameChanged(const QString &name)

value : QVariant

Specifica il valore del parametro

Funzioni di accesso:

QVariant value() const
void setValue(const QVariant &dv)

Segnale di notifica:

void valueChanged(const QVariant &value)

Documentazione delle funzioni membro

[explicit] QParameter::QParameter(Qt3DCore::QNode *parent = nullptr)

Crea un nuovo QParameter con l'parent e specificato.

[explicit] QParameter::QParameter(const QString &name, Qt3DRender::QAbstractTexture *texture, Qt3DCore::QNode *parent = nullptr)

Crea un nuovo oggetto QParameter con i valori specificati per i parametri “ parent ” e “ name ”, e ne ricava il valore da “ texture ”.

[explicit] QParameter::QParameter(const QString &name, const QVariant &value, Qt3DCore::QNode *parent = nullptr)

Crea un nuovo oggetto QParameter con i valori specificati per i parametri parent, name e value.

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