Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Load QML File from Source with QUrl
Qt 6.12 LTS is out! See what's new in the release blog

Load QML File from Source with QUrl

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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.

    raven-worxR 1 Reply Last reply
    0
    • ? A Former User

      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.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Fuel
      QUrl::fromLocalFile() expects a file path and returns an URL, so no need to already provide an URL.
      Try QUrl::fromLocalFile(":/qml/medislocation.qml")) or even qrc:///qml/medislocation.qml") instead

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      ? 1 Reply Last reply
      1
      • raven-worxR raven-worx

        @Fuel
        QUrl::fromLocalFile() expects a file path and returns an URL, so no need to already provide an URL.
        Try QUrl::fromLocalFile(":/qml/medislocation.qml")) or even qrc:///qml/medislocation.qml") instead

        ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        @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
        
        raven-worxR 1 Reply Last reply
        0
        • ? A Former User

          @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
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

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

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt
          • Unsolved