Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business


OverviewFelgo 1 Support › Read Infos from files

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #4661



    For a v-play game i need to read data from a simple txt file. But how? Google results aren’t realy helpfully. Can somebody help me?


    best wishes



    Felgo Team

    Hi Johanna,

    since version 1.3 we support file reading with System::readFile(). However, in most cases you can achieve a better code style by defining a base QML file (like a LevelBase.qml) and then create multiple instances of it by subclassing this QML file.

    Cheers, Chris



    After a failed VPlay update and a completely new installation VPlay 1.3 is running now đŸ™‚ And i’ve found the readFile() function.

    But we do not really understand why we need a base QML file. Do you mean for creating different levels?

    Greetings Johanna


    Felgo Team

    If you just read levels, it is easier to define the levels in QML file and you do not need the loading from a file.

    Have a look at the demo games like Squaby, where this concept is shown in detail.

    Consider the following code:

    Item {
     // the blocks variant could be any array or a map you define in the levels
     property variant blocks
    LevelBase {
     // enter any level data here you need for your game
     blocks: [[10, 30, 50], [5, 10, 5]]
    then, for loading the level:
    Loader {
     source: "Level01.qml" // select any level here, possibly from a level selection scene


    This is the suggested workflow with QML. File reading is only necessary if you also want to save some files, which is not the case I guess.

    Cheers, Chris



    ok. this sounds logical and easier than reading from a file đŸ™‚

    i’ve tried it. but i don’t understand how to get all the single stones out of my property in the BaseLevel.qml. So i have following qml files:

    BaseLevel.qml: contains a property with all data loaded from the Level.qml and a Loader (like shown in your post)

    Level01.qml: like shown in your post

    Stone.qml: implements mouse area, boxCollider, position, size of a stone. these data are saved in the property of the BaseLevel.qml. how can i access them?


    i’ve tried to get this information out of the code of Squaby but i couldn’t find what i searched for.. may you help me?


    Greetings, Johanna


    Felgo Team

    Hi Johanna,

    You can access the contents of the Loader with the item property. Please have look at the Loader documentation, or search for “Loader” in the demo games.

    Cheers, Chris

Viewing 6 posts - 1 through 6 (of 6 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded