Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. progress bar to show the process of adding item to list view
Qt 6.11 is out! See what's new in the release blog

progress bar to show the process of adding item to list view

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 944 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kook
    wrote on last edited by
    #1

    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 responding

        model = 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

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You don't need a progress bar for such a small workload.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        You don't need a progress bar for such a small workload.

        K Offline
        K Offline
        kook
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          But not because of the code you're showing. Or do you add 100k and more strings?

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          K 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            But not because of the code you're showing. Or do you add 100k and more strings?

            K Offline
            K Offline
            kook
            wrote on last edited by
            #5

            @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

            JonBJ 1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Fill your model in a separate thread, don't use convenience models but a custom one derived from QAbstractItemModel

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              K 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                Fill your model in a separate thread, don't use convenience models but a custom one derived from QAbstractItemModel

                K Offline
                K Offline
                kook
                wrote on last edited by
                #7

                @Christian-Ehrlicher thank you i will try that

                1 Reply Last reply
                0
                • K kook

                  @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

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #8

                  @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?)

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved