Не заполняется модель в ListView данными json
Народ ну помогите. Код взят из хабра, практически не изменен, но он не работает. Точнее js отрабатывает, в консоль летит выхлоп с json данными, но модель не заполняется. Код работал точно, т.к брал его же раньше и все было нормально. Может были какие то изменения в самой библиотеке. З.Ы. qt 5.10
Вот код
import QtQuick 2.9 import QtQuick.Window 2.2 Window { id: mainM property int userId: XXX //здесь ваш user_id property var friends width: 320 height: 640 color: 'skyblue' visible: true function getFriends() { var requ = new XMLHttpRequest() requ.open('POST', 'https://api.vk.com/method/friends.get') requ.onreadystatechange = function() { if(requ.readyState === XMLHttpRequest.DONE) { if(requ.status && requ.status === 200) { console.log("response", requ.responseText) var results = JSON.parse(requ.responseText) mainM.friends = results.response } else { console.log('HTTP:', requ.status, requ.responseText) } } } requ.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') requ.send('&fields=photo_medium' + '&user_id=' + mainM.userId + '&v=5.73') } ListView { id: view anchors.margins: 10 anchors.fill: parent model: friends spacing: 10 delegate: Rectangle { width: view.width height: 100 anchors.horizontalCenter: parent.horizontalCenter color: 'white' border { color: 'lightgray' width: 2 } radius: 10 Row { anchors.margins: 10 anchors.fill: parent spacing: 10 Image { id: image height: parent.height fillMode: Image.PreserveAspectFit source: modelData['photo_medium'] } Text { width: parent.width - image.width - parent.spacing anchors.verticalCenter: parent.verticalCenter elide: Text.ElideRight renderType: Text.NativeRendering text: "%1 %2".arg(modelData['first_name']).arg(modelData['last_name']) } } } } Component.onCompleted: { getFriends() } }
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
AD
- Akiv Doros
- Nov. 12, 2024, 1:58 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:50points,
- Rating points-4
m
- molni99
- Oct. 26, 2024, 11:37 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
m
- molni99
- Oct. 26, 2024, 11:29 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:20points,
- Rating points-10
Last comments
Qt/C++ - Lesson 031. QCustomPlot – The build of charts with time buy generic priligy We can just chat, and we will not lose too much time anyway
Qt/C++ - Lesson 060. Configuring the appearance of the application in runtime I didnt have an issue work colors priligy dapoxetine 60mg revia cost uk August 3, 2022 Reply
Circuit switching and packet data transmission networks Angioedema 1 priligy dapoxetine
How to Copy Files in Linux If only females relatives with DZ offspring were considered these percentages were 23 order priligy online uk
Qt/C++ - Tutorial 068. Hello World using the CMAKE build system in CLion ditropan pristiq dosing With the Yankees leading, 4 3, Rivera jogged in from the bullpen to a standing ovation as he prepared for his final appearance in Chicago buy priligy pakistan
Now discuss on the forum
добавить qlineseries в функции priligy amazon canada 93 GREB1 protein GREB1 AB011147 6
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
IscanderCheNov. 1, 2024, 1:43 a.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…
ИМ
Реализация навигации по разделам Спасибо Евгений!
Игорь МаксимовOct. 3, 2024, 2:05 p.m.
Ошибка в функции getFriends().