There is a table in which to insert data from a text file:
TableView { width: 640 height: 480 sortIndicatorOrder: 0 anchors.bottomMargin: 55 TableViewColumn { role: "user_id" // Эти роли совпадают с названиями ролей в C++ модели title: "User ID" } TableViewColumn { role: "username" // Эти роли совпадают с названиями ролей в C++ модели title: "Username" } TableViewColumn { role: "phone_number" // Эти роли совпадают с названиями ролей в C++ модели title: "Phone number" } // Устанавливаем модель в TableView model: myModel Button { x: 533 y: 441 text: "Задать путь!" //onClicked: main.main(); } TextInput { x: 250 y: 441 width: 224 height: 23 horizontalAlignment: Text.AlignLeft font.family: "Arial" cursorVisible: true } Text { id: pathtxt x: 8 y: 441 width: 223 height: 23 text: "Введите путь до файла с расширением .txt: " textFormat: Text.AutoText horizontalAlignment: Text.AlignLeft } Actually, it is impossible to think of an algorithm for insertion:
int main(int argc, char *argv[]){ QGuiApplication app(argc, argv); QString path; QFile file1(path); if(file1.exists()) { QTextStream stream1(&file1); while(!stream1.atEnd()) { QString line = stream1.readLine(); QStringList standartStringList; for (QString item : line.split(";")) { standartStringList.append(item); } }} QQuickView view; QQmlContext *ctxt = view.rootContext(); ctxt->setContextProperty("myModel", standartStringList); view.setSource(QUrl("qrc:main.qml")); view.show(); return app.exec();} PS displays each word in one line (that is, in the userid, username, phonenumber, the same word is displayed when each word is needed separately)
dataListcome from? - Alexander Chernin