In questa pagina

QQmlError Class

La classe QQmlError incapsula un errore QML. Per saperne di più...

Intestazione: #include <QQmlError>
CMake: find_package(Qt6 REQUIRED COMPONENTS Qml)
target_link_libraries(mytarget PRIVATE Qt6::Qml)
qmake: QT += qml

Funzioni pubbliche

QQmlError()
QQmlError(const QQmlError &other)
int column() const
QString description() const
bool isValid() const
int line() const
QtMsgType messageType() const
QObject *object() const
void setColumn(int column)
void setDescription(const QString &description)
void setLine(int line)
void setMessageType(QtMsgType messageType)
void setObject(QObject *object)
void setUrl(const QUrl &url)
QString toString() const
QUrl url() const
QQmlError &operator=(const QQmlError &other)
QDebug operator<<(QDebug debug, const QQmlError &error)

Descrizione dettagliata

QQmlError include una descrizione testuale dell'errore, oltre alle informazioni sulla posizione (file, riga e colonna). Il metodo toString() crea una stringa di una sola riga, leggibile dall'utente, contenente tutte queste informazioni, ad esempio:

file:///home/user/test.qml:7:8: Invalid property assignment: double expected

È possibile utilizzare qDebug(), qInfo() o qWarning() per visualizzare gli errori sulla console. Questo metodo tenterà di aprire il file indicato dall'errore e includerà ulteriori informazioni contestuali.

file:///home/user/test.qml:7:8: Invalid property assignment: double expected
        y: "hello"
           ^

Vedi anche QQuickView::errors() e QQmlComponent::errors().

Documentazione sulle funzioni membro

QQmlError::QQmlError()

Crea un oggetto di errore vuoto.

QQmlError::QQmlError(const QQmlError &other)

Crea una copia di other.

int QQmlError::column() const

Restituisce il numero della colonna dell'errore.

Vedi anche setColumn().

QString QQmlError::description() const

Restituisce la descrizione dell'errore.

Vedi anche setDescription().

bool QQmlError::isValid() const

Restituisce true se l'errore è valido, altrimenti false.

int QQmlError::line() const

Restituisce il numero di riga dell'errore.

Vedi anche setLine().

QtMsgType QQmlError::messageType() const

Restituisce il tipo di messaggio.

Vedi anche setMessageType().

QObject *QQmlError::object() const

Restituisce l'oggetto più vicino in cui si è verificato l'errore. Le eccezioni nelle espressioni delle proprietà associate impostano questo valore sull'oggetto a cui appartiene la proprietà. Per tutte le altre eccezioni, il valore sarà 0.

Vedi anche setObject().

void QQmlError::setColumn(int column)

Imposta il numero di errore " column ".

Vedi anche column().

void QQmlError::setDescription(const QString &description)

Imposta l'description e di errore.

Vedi anche description().

void QQmlError::setLine(int line)

Imposta il numero di errore " line ".

Vedi anche line().

void QQmlError::setMessageType(QtMsgType messageType)

Imposta il campo " messageType " per questo messaggio. Il tipo di messaggio determina quali gestori QDebug sono incaricati di ricevere il messaggio.

Vedi anche messageType().

void QQmlError::setObject(QObject *object)

Indica l'object e più vicina in cui si è verificato questo errore.

Vedi anche object().

void QQmlError::setUrl(const QUrl &url)

Imposta il parametro " url " per il file che ha causato questo errore.

Vedi anche url().

QString QQmlError::toString() const

Restituisce l'errore sotto forma di stringa leggibile dall'utente.

QUrl QQmlError::url() const

Restituisce l'URL del file che ha causato questo errore.

Vedi anche setUrl().

QQmlError &QQmlError::operator=(const QQmlError &other)

Assegna ` other ` a questo oggetto di errore.

Elementi non membri correlati

QDebug operator<<(QDebug debug, const QQmlError &error)

Genera una versione leggibile da un utente di error e la invia a debug.

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