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:
LevelBase.qml:
Item {
// the blocks variant could be any array or a map you define in the levels
property variant blocks
}
Level01.qml:
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