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 overwrite in a console Application

How to overwrite in a console Application

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 1.2k Views 2 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.
  • Z Offline
    Z Offline
    Zac.Boussaid
    wrote on last edited by
    #1

    Hey guys, I have a little problem which is I’m updating my output every 50 ms but I don't want the output to display several times, but just want to directly rectify the given display.
    overwrite.png

    jsulmJ 1 Reply Last reply
    0
    • Z Zac.Boussaid

      Hey guys, I have a little problem which is I’m updating my output every 50 ms but I don't want the output to display several times, but just want to directly rectify the given display.
      overwrite.png

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Zac-Boussaid said in How to overwrite in a console Application:

      but I don't want the output to display several times

      What do you mean?
      Please explain better what exactly you want and what you get.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

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

        Hi
        There is little console/cursor control in plain c++.

        You could use ncurses or Termbox or anything similar.

        http://www.cplusplus.com/articles/4z18T05o/

        1 Reply Last reply
        2
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          The most robust way to do what you want would be to use the ncurses library.

          Otherwise, this stack overflow answer looks pretty good (not tested myself, but the logic looks correct).

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          Z 1 Reply Last reply
          1
          • jsulmJ jsulm

            @Zac-Boussaid said in How to overwrite in a console Application:

            but I don't want the output to display several times

            What do you mean?
            Please explain better what exactly you want and what you get.

            Z Offline
            Z Offline
            Zac.Boussaid
            wrote on last edited by
            #5

            @jsulm i would like to have something similar to this picture:
            clear.png
            The output is displayed once this is because i'm calling my function just one time. now if i want to call the same function several of time to update the output but without displaying that more than one time
            see Picture bellow

            1 Reply Last reply
            0
            • SGaistS SGaist

              Hi,

              The most robust way to do what you want would be to use the ncurses library.

              Otherwise, this stack overflow answer looks pretty good (not tested myself, but the logic looks correct).

              Z Offline
              Z Offline
              Zac.Boussaid
              wrote on last edited by Zac.Boussaid
              #6

              @SGaist i'm using qDebug() , not cout. I tried to use flush but i didn't get what i want. i tried even to give my output with cout but suddenly i get the smae thing

              JonBJ 1 Reply Last reply
              0
              • Z Zac.Boussaid

                @SGaist i'm using qDebug() , not cout. I tried to use flush but i didn't get what i want. i tried even to give my output with cout but suddenly i get the smae thing

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by JonB
                #7

                @Zac-Boussaid
                The simple answer is I don't think you can do this. @SGaist's stackoverflow post does what I thought of, which is emit \r carriage-returns to move the cursor back to the start of a line to overwrite. But that would only work for one line, and what you want is to "back up" 8 lines each time, and I don't know of any way to do that. Other than @SGaist's suggestion of ncurses, which is a whole different ball-game.

                Z 1 Reply Last reply
                0
                • JonBJ JonB

                  @Zac-Boussaid
                  The simple answer is I don't think you can do this. @SGaist's stackoverflow post does what I thought of, which is emit \r carriage-returns to move the cursor back to the start of a line to overwrite. But that would only work for one line, and what you want is to "back up" 8 lines each time, and I don't know of any way to do that. Other than @SGaist's suggestion of ncurses, which is a whole different ball-game.

                  Z Offline
                  Z Offline
                  Zac.Boussaid
                  wrote on last edited by
                  #8

                  @JonB thank you for your answer, At least i have an idea now

                  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