开发者

C++ qt control cursor position in console

开发者 https://www.devze.com 2023-03-07 00:04 出处:网络
I\'m writing a Qt console application. I need functions to control cursor position in console(gnome-terminal)(move it ba开发者_开发知识库ck, forward, on the nex-previous line).

I'm writing a Qt console application. I need functions to control cursor position in console(gnome-terminal)(move it ba开发者_开发知识库ck, forward, on the nex-previous line).

I have tried to seek this functions in QtCore, but unsuccessful. Does Qt have at all such tools?


AFAIK, Qt does not have any functions for abstracting the console in such a manner.

You can probably use another library rather easily, as it is unlikely to interfere with Qt much.


For Qt try this (It works for me, Qt 5.10, compiler: msvc2015):

#include <Windows.h>
...
int main()
{
 QCoreApplication a(argc, argv);
...
HANDLE hConsole_c = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos = {40, 20};
SetConsoleCursorPosition(hConsole_c,pos);
cout << "x";
...
return a.exec()
}
0

精彩评论

暂无评论...
验证码 换一张
取 消