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. [SOLVED]Reading and updating progress bar
Forum Update on Monday, May 27th 2025

[SOLVED]Reading and updating progress bar

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 2.8k Views
  • 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.
  • S Offline
    S Offline
    saeedhardan
    wrote on 4 Sept 2014, 14:32 last edited by
    #1

    i'm reading a very big text file and for each line i call a parser function , basically the "reading" of the file takes up a considerable amount of time .
    i want to attach a progress bar that shows how much i have read so far , meaning if there is way to get total number of lines plus i can define a counter for each line i read then the percent would be (count/total number of lines) .

    can it be done ?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dheerendra
      Qt Champions 2022
      wrote on 4 Sept 2014, 14:50 last edited by
      #2

      Yes. This can be done. While reading the file continuously you need to keep processing the events to ensure that UI is updated. i.e call processEvents(..). If not use threads to process the file and update the UI using signal and slot or events.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saeedhardan
        wrote on 4 Sept 2014, 15:19 last edited by
        #3

        [quote author="Dheerendra" date="1409842241"]Yes. This can be done. While reading the file continuously you need to keep processing the events to ensure that UI is updated. i.e call processEvents(..). If not use threads to process the file and update the UI using signal and slot or events.[/quote]

        maybe my question wasn't clear , sorry , i meant how to get total number of lines a file contains ?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dheerendra
          Qt Champions 2022
          wrote on 4 Sept 2014, 16:52 last edited by
          #4

          You need to count manually. There is no direct one shot api. U can do it based on the size than lines.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • S Offline
            S Offline
            saeedhardan
            wrote on 4 Sept 2014, 16:55 last edited by
            #5

            Can you pls explain how to do it by size ?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              arsinte_andrei
              wrote on 4 Sept 2014, 22:16 last edited by
              #6

              Here you can use "QFileInfo":http://qt-project.org/doc/qt-5/qfileinfo.html#size
              this will give you that file size then according to the size that you are reading you can implement a progress bar that will be updated with a signal and slot mechanism fount in Qt

              1 Reply Last reply
              0
              • S Offline
                S Offline
                saeedhardan
                wrote on 4 Sept 2014, 22:27 last edited by
                #7

                Thank you sir

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  arsinte_andrei
                  wrote on 4 Sept 2014, 22:33 last edited by
                  #8

                  if that solve your problem please edit your first post title and add [SOLVED] in order for others to know that is solved

                  1 Reply Last reply
                  0

                  1/8

                  4 Sept 2014, 14:32

                  • Login

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