qt 隐藏控制台_QT控制台的屏幕有多清晰?(How clear screen in QT console?)

QT控制台的屏幕有多清晰?(How clear screen in QT console?)

我需要清晰的QT控制台。 什么是命令?

main.cpp中:

int main(int argc, char *argv[])

{

QCoreApplication a(argc, argv);

cout<

//system("CLS")?

return a.exec();

}

I need clear QT console. What is the comand?

main.cpp:

int main(int argc, char *argv[])

{

QCoreApplication a(argc, argv);

cout<

//system("CLS")?

return a.exec();

}

原文:https://stackoverflow.com/questions/20028213

更新时间:2020-04-07 18:04

最满意答案

你可以执行:

QProcess::execute("CLS");

这当然只适用于Windows。 在Linux / Unix-ish系统上,您需要执行以下操作:

QProcess::execute("clear");

如果你需要做的只是清除屏幕,这些东西都可以。 但是,如果您正在尝试构建更复杂的基于文本的界面(某些行已修复,或者您想绘制一些进度指示器等),则需要更复杂的东西。

在Windows上,有一个curses端口调用PDCurses: http ://pdcurses.sourceforge.net/。 这将让您运行与ncurses几乎相同的代码。 如果您只关注Windows,可以查看Windows的Console API: http : //msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx

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

2013-11-17

相关问答

您可以使用自定义方法清除屏幕的某些部分... static void Clear(int x, int y, int width, int height)

{

int curTop = Console.CursorTop;

int curLeft = Console.CursorLeft;

for (; height > 0;)

{

Console.SetCursorPosition(x, y + --height);

Console

...

描述 您可以使用Console.SetCursorPosition函数转到特定的行号。 你可以使用这个功能来清除线 public static void ClearCurrentConsoleLine()

{

int currentLineCursor = Console.CursorTop;

Console.SetCursorPosition(0, Console.CursorTop);

Console.Write(new string(' ', Console.Wind

...

如果打印到stderr足够好,可以使用以下用于调试的流: //qInfo is qt5.5+ only.

qInfo() << "C++ Style Info Message";

qInfo( "C Style Info Message" );

qDebug() << "C++ Style Debug Message";

qDebug( "C Style Debug Message" );

qWarning() << "C++ Style Warning Message";

qWarning(

...

在Mac OS X或Linux上,您可以使用Ctrl + L清除IRB屏幕。 On Mac OS X or Linux you can use Ctrl + L to clear the IRB screen.

/ opt由root拥有,您需要授予用户chmod + x qtcreator权限。 /opt is owned by root , you need to give permission to user chmod +x qtcreator.

RInside的其中一个例子做的非常接近 - 大约有200行,其中大部分涉及其他GUI方面,它将R功能封装在Qt应用程序中。 该示例实现了一个GUI密度滑块,编辑框允许您编写一个几乎任意的R表达式,或者更确切地说,将这些部分传递到评估中以生成随机数: rnorm(50)或混合c(rnorm(50), rt(50))等。你可能会建立在此之上。 看到这篇博客文章了解更多。 One of the examples for RInside does something pretty close---in

...

我找到了解决方案:我在* .pro文件中: QT += core

TARGET = MyPlugin

TEMPLATE = lib

CONFIG += plugin

并且似乎默认包含“gui”模块,因此: QT -= gui

解决了这个问题。 I figured out the solution : I had in the *.pro file : QT += core

TARGET = MyPlugi

...

你只需要使用外部库而不是内部。 You just have to use the external library instead of the internal.

你可以执行: QProcess::execute("CLS");

这当然只适用于Windows。 在Linux / Unix-ish系统上,您需要执行以下操作: QProcess::execute("clear");

如果你需要做的只是清除屏幕,这些东西都可以。 但是,如果您正在尝试构建更复杂的基于文本的界面(某些行已修复,或者您想绘制一些进度指示器等),则需要更复杂的东西。 在Linux上有ncurses: http : //www.gnu.org/software/ncurses/ 在Wi

...

嗯,要求不明确,我不会这样推荐,但所述问题可能会通过以下方式解决: $stdout.singleton_class.prepend(Module.new do

def write(string)

super("\e[2J" << string)

end

end)

我认为,这个答案不适合OP,但它完全回答了所提出的确切问题 。 Well, the requirements are not clear and I won’t recommend this way, but the s

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值