Including a text file in qml
-
- QML Store your jokes in a ListModel or an JavaScript array.
- QML/C++ Store your jokes in a ListModel or an JavaScript array or distribute it along with your application (either as file or as a resource), parse it (using C++ code) to a QStringList and expose this list using a context property.
-
okay. i based my actions on your answer.
i stored my contents inside a text file (our professor's requiring us to do so)
i made this code
@import QtQuick 1.0
import com.nokia.symbian 1.0Page {
id: lolPage
objectName: "lolPage"ListModel { id: jokeModel ListElement{ joke: Qt.resolvedUrl(jokes.text = TextFile.readLine()) } Component{ id: jokeDelegate ListItem{ height: 200 Column{ Text{ id: textJoke text: joke color: "black" font.pixelSize: 20 } } } } ListView{ anchors.fill: parent model: jokeModel delegate: jokeDelegate } }@
what am i doing wrong here? i do not know how to call and display the contents of an external file using ListModel.