How to use scrollbar in QListView
@ QFileInfo fileinfo = QFileInfo(fileName);
while i open a file, I want to use QListView to show all the files in this folder, and meanwhile, get the scrollbar scroll tho the file.
But the scrollbar remain in the top when all the files showed. Then, when i open another file in this folder, the scrollbar work well.
I debug to see how scrollToBottom() work, i find when i first open a file, the maximum value of the scrollbar remain ZERO.
Is there any way, when i first load a file, the scrollbar will scroll to the file automatically.
Hi and welcome to devnet,
To change the folder, you need to call setRooIndex with the appropriate index
[quote author="SGaist" date="1407966298"]Hi and welcome to devnet,
To change the folder, you need to call setRooIndex with the appropriate index[/quote]
but I have opened the folder correctly, but the scrollbar doesn't work well, as it doesn't scroll to the correct position, it still remain the top,
That's strange, what version of Qt are you using ? On what OS ?
[quote author="SGaist" date="1408487317"]That's strange, what version of Qt are you using ? On what OS ?[/quote]
Thx, i have solved it recently.
This is because when i use
, the model is not set immediately. I just find it by debugging setModel() :D.
Then i find this singal of Q***Model
this signal can be used here, but i think this is not the best solution. as before the model is completely loaded, the signal is emitted several times.
Indeed ! Detail I forgot, the QFileSystemModel is threaded