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. Singleton Context Issues
Forum Updated to NodeBB v4.3 + New Features

Singleton Context Issues

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 681 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.
  • K Offline
    K Offline
    Kevanov
    wrote on last edited by
    #1

    Hi everyone, let start with some simplified code:

    ScreenManager.qml:

    @pragma Singleton
    import QtQuick 2.3

    Item {

    function createScreen(fileName, parentItem, obj){
        var newScreen = Qt.createComponent(fileName);
        newScreen.createObject(parentItem, obj);
    }
    

    }
    @

    Main.qml:

    @ Component.onCompleted: {
    ScreenManager.createScreen("AnyScreen.qml", root, {"source": "qrc:/images/blabla.png"})
    }@

    Even though I pass a root reference to the singleton function, it doesnt consider my newly created object "AnyScreen.qml" as a child of my root.

    It seems like because the creation context is within the singleton, I just get a blank screen instead of what I had before. Anyone know how I could solve this problem ?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kevanov
      wrote on last edited by
      #2

      I just found the problem:

      @var newScreen = Qt.createComponent("qrc:/" + fileName);@

      If i dont prefix with qrc:/ it will try to load the file from qrc:/singletonfolder/

      Good news is that everything is working !!!

      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