Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How clear screen in QT console?

I need clear QT console. What is the comand?

main.cpp:

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    cout<<"How delete this?";
    //system("CLS")?
    return a.exec();
}
like image 325
punksta Avatar asked Oct 02 '22 10:10

punksta


1 Answers

You can execute:

QProcess::execute("CLS");

This will of course only work on Windows. On Linux/Unix-ish systems, you'll need to do:

QProcess::execute("clear");

If all you need to do is clear the screen, these things will work. However, if you're trying to build a more sophisticated text-based interface (where certain lines are fixed, or if you want to draw some progress indicators or the like), you'll need something more sophisticated.

  • On Linux there's ncurses: http://www.gnu.org/software/ncurses/
  • On Windows, there's a curses port call PDCurses: http://pdcurses.sourceforge.net/. This will let you run nearly the same code as ncurses. If you're only focused on Windows, you can look at Windows' Console API: http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx
like image 143
ksimons Avatar answered Oct 13 '22 10:10

ksimons