Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Import causes QML Item to not load
Qt 6.11 is out! See what's new in the release blog

Import causes QML Item to not load

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 625 Views
  • 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.
  • T Offline
    T Offline
    therealmatiss
    wrote on last edited by
    #1

    Hello! I have a weird problem - whenever I'm trying to import my C++ "backend" to QML, the QML GUI doesn't even load.

    I have an application that launches loader.qml from C++, which source is stackview.qml.

    Loader QML:

    import QtQuick
    import QtQuick.Window
    
    Window {
      id: window
      width: 800
      height: 480
      visible: true
      color: "#000000"
      title: qsTr("Test")
    
      Loader {
        id: mainLoader
        anchors {
          left: parent.left
          right: parent.right
          top: parent.top
          bottom: parent.bottom
        }
        source: "stackview.qml"
      }
    }
    

    Stackview QML

    import QtQuick
    import QtQuick.Controls
    
    import MyApp.Backend // If I comment this out, everything works
    
    Item {
      anchors.fill: parent
    
      StackView {
        id: mainStackview
        anchors.fill: parent
        initialItem: "screen_main.qml"    
    
        Connections {
          target: cppStackview
          onChangeScreen: {
            console.log("Screen change to : " + screen_url)
            mainStackview.push(screen_url)
          }
        }
      }
    }
    

    Keep in mind, that I'm using import MyApp.Backend in other QML files and it works fine. I guess it's because it's the first .qml file that's being loaded? There are no logs from Qt on this - it simply shows blank screen.

    1 Reply Last reply
    0
    • GrecKoG Online
      GrecKoG Online
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      Try running your application with the QML_IMPORT_TRACE set to 1 and look at the messages in the console.

      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 Extensions
      • Unsolved