progress bar to show the process of adding item to list view
-
Hi,
i am adding items(messages) to my list view, some times the num of message needs to be added are more so it takes a little time to show messages on listview i would like to show this progress using a progress bar so the user the apllication is respondingmodel = new QStringListModel(this); num_of_msg = get_num_of_msg(); Display_messages_on_list_view();when the function call Display_messages_on_list_view(); happens progress bar should start and when it finishes all the messages should be displayed
void MainWindow::Display_messages_on_list_view() { for(int i=0; i<num_of_msg;i++) { list.append(QString::number(i)); } model->setStringList(list); ui->listView->setModel(model); }so i dont know where i should have the progressbar and with what value i should increment
do i need to start progress bar in a separate thread ??
please some one suggest me how should i implement it -
You don't need a progress bar for such a small workload.
-
You don't need a progress bar for such a small workload.
@Christian-Ehrlicher sometimes it takes few min to show all the messages and it looks like the application is not responding that is why i thought of having a progressbar
-
But not because of the code you're showing. Or do you add 100k and more strings?
-
But not because of the code you're showing. Or do you add 100k and more strings?
@Christian-Ehrlicher yea the data i am appending to the list is more like this
list.append(msg_ptr->msgname); list.append(msg_ptr->msgnum);msg_ptr is a pointer to the structure
i am really sorry i cannot post the actual code here so i provided the snippet of what i am trying to do
-
Fill your model in a separate thread, don't use convenience models but a custom one derived from QAbstractItemModel
-
Fill your model in a separate thread, don't use convenience models but a custom one derived from QAbstractItemModel
@Christian-Ehrlicher thank you i will try that
-
@Christian-Ehrlicher yea the data i am appending to the list is more like this
list.append(msg_ptr->msgname); list.append(msg_ptr->msgnum);msg_ptr is a pointer to the structure
i am really sorry i cannot post the actual code here so i provided the snippet of what i am trying to do
@kook said in progress bar to show the process of adding item to list view:
@Christian-Ehrlicher yea the data i am appending to the list is more like this
That's not really the point though. Just how many (approximately)
list.append()s are you doing? Like 100,000? Or what sort of number? How many messages? (Just the 2 fields you show are added per message?)