Modernize snippet

It referenced QDeclarativeComponent, which has been gone for a very long
time. Also replace the foreach with a proper for loop.

Change-Id: I7f30ca10a235137dbdf34b7684e2c38610242b17
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
bb10
Fabian Kosmale 2023-08-08 12:06:33 +02:00
parent 47b879aa0b
commit 8eca7fffa3
1 changed files with 4 additions and 4 deletions

View File

@ -3,12 +3,12 @@
#include <QtGui>
#include <QtDebug>
#include <QDeclarativeComponent>
#include <QQmlComponent>
//! [1]
void statusChanged(QDeclarativeComponent::Status status) {
if (status == QDeclarativeComponent::Error) {
foreach (const QDeclarativeError &error, component->errors()) {
void statusChanged(QQmlComponent::Status status) {
if (status == QQmlComponent::Error) {
for (const QQmlError &error: std::as_const(component->errors())) {
const QByteArray file = error.url().toEncoded();
QMessageLogger(file.constData(), error.line(), 0).debug() << error.description();
}