Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

qml live bench tool



  • hi,

    Does someone know how to make my qml singleton Component available for the Qml Live Bench tool ?

    The singleton component contains my application style (colors/font ratio ..) , it looks like this

    //Style.qml
    pragma Singleton
    //imports
    Item {
         property string darkBlueColor: "#005490"  
         property string lightBlueColor: "#006BB7"
    //...
    }
    

    and i use it like this

    // MyComponent.qml
    import "style"
    
    Rectangle{
       color : Style.darkBlueColor
    }
    

    but if i run my MyComponent in QML Live Bench i get this output

     Unable to assign [undefined] to QColor
    

    I tryed to add the folder that contains Style.qml to Qml Live Bench by doing :

    File > Preferences... > Import Paths > add



  • This post is deleted!


  • I found an alternative to this,

    i simply defined my constants in a Js lib (.pragma library) instead of QML Singleton

    // Consts.js
    .pragma library
    
     property string darkBlueColor: "#005490"  
     property string lightBlueColor: "#006BB7"
    

Log in to reply