Solved qml QListview updating slow by c++
-
I'm updating the qml Listview from c++ like;
in main.cpp;
listeci frmlisteci; engine.rootContext()->setContextProperty("listeElemanlar", &frmlisteci.listeElemanlar);
in Liste.qml;
ListView{ id: listeciElemanlar anchors.fill: parent model: listeElemanlar delegate: Text{ text: display verticalAlignment: Text.AlignBottom width : parent.width color: textRengi font.pointSize: 30 leftPadding: 20 }}
in listeci.h;
public: QStringListModel listeElemanlar; private: QStringList userAyarlari;
in listeci.cpp;
listeci::listeci(QObject *parent) : QObject(parent) { // Kullanıcı ayarları elemanları userAyarlari.append("Kullanıcı ayarı 01"); userAyarlari.append("Kullanıcı ayarı 02"); userAyarlari.append("Kullanıcı ayarı 03"); userAyarlari.append("Kullanıcı ayarı 04"); userAyarlari.append("Kullanıcı ayarı 05"); userAyarlari.append("Kullanıcı ayarı 06"); userAyarlari.append("Kullanıcı ayarı 07"); userAyarlari.append("Kullanıcı ayarı 08"); userAyarlari.append("Kullanıcı ayarı 09"); userAyarlari.append("Kullanıcı ayarı 10"); userAyarlari.append("Kullanıcı ayarı 11"); userAyarlari.append("Kullanıcı ayarı 12"); userAyarlari.append("Kullanıcı ayarı 13"); userAyarlari.append("Kullanıcı ayarı 14"); userAyarlari.append("Kullanıcı ayarı 15"); userAyarlari.append("Kullanıcı ayarı 16"); userAyarlari.append("Kullanıcı ayarı 17"); userAyarlari.append("Kullanıcı ayarı 18"); userAyarlari.append("Kullanıcı ayarı 19"); } void listeci::listeGuncelle() { listeElemanlar.setStringList(userAyarlari); }
with these lines, I can successfully create a list and show on qml Listview, when I clicked on a button on qml side by calling
frmlisteci.listeGuncelle()
But when I do this procedure after a mount,( we can say refreshing the list) the code becoming slow, and waiting on this line:
listeElemanlar.setStringList(userAyarlari);
What can be the reason ?
Edit : 1
I just discover sth.
On my project, I have 5 qml pages and I'm navigating between the pages with "Stackview".
Here is the construction of stackview.
// Sayfa bölmesi StackView { id: stackci initialItem: manuelSayfa anchors.fill : sayfaBolmesi pushEnter: Transition { PropertyAnimation { property: "opacity" from: 0 to: 1 duration: 0 } } pushExit: Transition { PropertyAnimation { property: "opacity" from: 1 to: 0 duration: 0 } } } Component{ id:manuelSayfa Manuel{} } Component{ id:otomatikSayfa Otomatik{} } Component{ id:ayarlaraGirisSayfa AyarlaraGiris{} } Component{ id:listelerSayfa Liste{} } Component{ id:bilgiSayfa Bilgi{} }
And I'm navigating the pages with a signal from c++ like;
on main.qml
Connections{ target: sayfaDegistirmeReferansi onSayfaDegistir:{ sayfaDegistir(s) } } ....... function sayfaDegistir(sayfa) { if(sayfa == 100) stackci.push(manuelSayfa) ....... }
on main.cpp
engine.rootContext()->setContextProperty("sayfaDegistirmeReferansi",&frmkeypad);
My algorithm is like, when I send a signal to qml from c++, it first refresh the list, than open the page.
The thing that I discovered is, when I refresh the list with MouseArea ( also same with signal from c++), it doesnt make a delay on refreshing the list.
The difference is, I dont reload the page, only reloading the list....
So what can be the problem ????
Edit : 2
I solved the problem.
It is caused by stackview. I had used push method for changing the page.
When I changed push method by replace, everything started to work well.....
-
@bladekel said in qml QListview updating slow by c++:
this procedure after a mount
What's a mount?
waiting on this line:
listeElemanlar.setStringList(userAyarlari);
This is probably due to the model having to reset itself completely. can you edit it instead?
Also to test the speed with C++ and QML interactions use the release build, the debug becomes pretty heavy -
@VRonin
amount is not so much. It increase by every call such as on 10th 1sec waiting, on 20th 2sec waiting ... and so on.... -
I discovered sth and edit my first post....