Unsolved Load QML File from Source with QUrl
-
For the QLocation Plugin i try to load a QML File to a QGraphicsView and find this http://doc.qt.io/qt-4.8/qml-integration.html
but at the moment i get an Assert like this with following Code.QQmlEngine *engine = new QQmlEngine(); QQmlComponent component(engine, QUrl::fromLocalFile("qrc:/qml/medislocation.qml")); QGraphicsObject *object = qobject_cast<QGraphicsObject*>(component.create()); ui->gvMedisLocation->scene()->addItem(object);
ASSERT: "!url.isRelative() && (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() || !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url)))" in file qml\qqmltypeloader.cpp, line 1637 qml\qqmltypeloader.cpp: 1637
Anyone can explain me that? I try to import QLocation in my DesktopApp and i dont use QtQuick, so i need to import for this Map Function a QML File.
-
@Fuel
QUrl::fromLocalFile()
expects a file path and returns an URL, so no need to already provide an URL.
TryQUrl::fromLocalFile(":/qml/medislocation.qml"))
or evenqrc:///qml/medislocation.qml")
instead -
@raven-worx said in Load QML File from Source with QUrl:
Try QUrl::fromLocalFile(":/qml/medislocation.qml")) or even qrc:///qml/medislocation.qml") instead
Both Arguments dont work. I get the same Assert.
When i use this QUrl::fromLocalFile(":/qml/medislocation.qml")) i get this
QML debugging is enabled. Only use this in a safe environment. QML Debugger: Waiting for connection on port 56726... [09:20:53:08:628][10364] IGIESW c:\users\benni\documents\build-kt-desktop_qt_5_9_2_mingw_32bit2-debug\debug\kt.exe found in whitelist: NO [09:20:53:08:705][10364] IGIWHW Game c:\users\benni\documents\build-kt-desktop_qt_5_9_2_mingw_32bit2-debug\debug\kt.exe found in whitelist: NO setGeometry: Unable to set geometry 100x100+880+440 on QQuickWindow/''. Resulting geometry: 120x100+880+440 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215). ASSERT: "!m_thread.isRunning()" in file qqmldebugserver.cpp, line 655
-
@Fuel said in Load QML File from Source with QUrl:
Both Arguments dont work. I get the same Assert.
really? The 2 messages seem pretty different to me. So i would say your initial issue is solved.
Now you have another one. But i don't know whats the cause though.