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

files are automatically imported as objects?



  • I'm very new to QML and QtQuick, so I apologize if the following is a bad question. If the answers could be easily found in some documentation, please point me in that direction, thanks.

    I am trying to change SDDM login on my Lubuntu OS. The appearance is managed by a file called "Main.qml", which imports QtQuick 2.0 and SddmComponents2.0. The code in this file references an object called "PictureBox", which doesn't seem to exist in QtQuick. I assume PictureBox object is created by "PictureBox.qml", part of SDDM components:
    https://github.com/jhonwoo/sddm/tree/master/components/2.0

    PictureBox.qml only imports QtQuick2.0, but it uses another object I can't find in QtQuick called PasswordBox. So, can I assume that QML files located in the same directory can automatically import each other without explicit import statements?

    Also, if I want to modify PictureBox object in any way, can I do this from Main.qml, or do I have to modify the PictureBox.qml file?

    Thanks.


  • Moderators

    @anotherChris said in files are automatically imported as objects?:

    So, can I assume that QML files located in the same directory can automatically import each other without explicit import statements?

    Yes.

    Also, if I want to modify PictureBox object in any way, can I do this from Main.qml, or do I have to modify the PictureBox.qml file?

    You can modify properties of objects where you use them. So for example:

    Item {
     x: 5
     y: 20
    }
    

    x and y are properties defined in Item.qml, but you can manipulate them in your file. If you want to add a property, you can do it, too:

    Item {
     property int coord: 20
     x: coord + 8
     y: coord
    }
    

    But if you want to do deeper modifications of item (like - remove a property), you need to do it in the source file.



  • @sierdzio Thank you!


Log in to reply