The function is overloaded:
void QDeclarativeContext
::setContextProperty ( const QString & name,
QObject * value
) void QDeclarativeContext
::setContextProperty ( const QString & name,
const QVariant & value
)
void QDeclarativeContext::setContextProperty ( const QString & name, QObject * value )
void QDeclarativeContext::setContextProperty ( const QString & name, const QVariant & value )
To copy to clipboard, switch view to plain text mode
You give the compiler a second argument of bool. Since neither overload takes a bool argument explicitly the compiler tries to find a match by casting. In both cases it chooses the QObject* version and issues the warning because using a bool to initialise a pointer is unusual.
Do this to avoid the warning by forcing the QVariant version:
QQmlApplicationEngine engine;
#ifdef QT_DEBUG
engine.
rootContext()->setContextProperty
("QT_DEBUG",
QVariant(true));
#else
engine.
rootContext()->setContextProperty
("QT_DEBUG",
QVariant(false));
#endif
QQmlApplicationEngine engine;
#ifdef QT_DEBUG
engine.rootContext()->setContextProperty("QT_DEBUG", QVariant(true));
#else
engine.rootContext()->setContextProperty("QT_DEBUG", QVariant(false));
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks