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. How to make inprocess or progressbar in console app
QtWS25 Last Chance

How to make inprocess or progressbar in console app

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.0k 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.
  • K Offline
    K Offline
    Kien Bui
    wrote on last edited by
    #1

    Show processing on console app
    Ex:

    Processing.
    Processing..
    Processing...
    

    OR

    Process: 10%
    Process: 15%
    Process: 20%
    .....
    Done
    

    But all text only one line, older text is removed.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      There are various ways
      https://stackoverflow.com/questions/28350254/how-do-i-rewrite-a-line-of-text-in-a-console-project-c

      1 Reply Last reply
      0
      • AlfredoRamosA Offline
        AlfredoRamosA Offline
        AlfredoRamos
        wrote on last edited by
        #3

        You can do it with something like:

        for(unsigned short int i = 0; i <= 100; i++) {
        	std::cout << QString("\rProgress: %1").arg(
        		i < 100 ? QString("%1%").arg(i) : "Done"
        	).toStdString() << std::flush;
        	std::this_thread::sleep_for(std::chrono::milliseconds(50));
        }
        

        Libraries needed to run this example: iostream, thread and chrono

        1 Reply Last reply
        2

        • Login

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