小编pog*_*dhu的帖子

如何使窗口出现在所有内容之上(甚至是全屏游戏!)c ++/Qt

我正在尝试使应用程序在屏幕中央显示十字准线并保持其他所有内容.目的是在一些没有提供的FPS游戏中使用十字准线.除了游戏之外,我已经成功地将窗口放在最顶层:/

这是我的代码:(一切都在主要,因为我只测试我的应用程序的核心功能,我已经广泛评论它试图让我的问题更容易访问)

QApplication app(argc, argv);

DWORD error;
QWidget window;
QLabel *label = new QLabel(&window);
label->setText("<strong>O<strong>");//I'm using an "O" as a crosshair until I can figure out how to display image transparency.
window.setGeometry(960-label->width()/2,540-label->height()/2,label->width(),label->height());//here I'm making my window appear in the center of my screen
window.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);// here making the window frameless and topMost via qt
window.setAttribute(Qt::WA_TranslucentBackground);//making the window see through
window.setWindowTitle("Crosshair");
window.show();

//in this next part I tried using windows api to make my window appear on top of the …
Run Code Online (Sandbox Code Playgroud)

c++ qt topmost

9
推荐指数
1
解决办法
8296
查看次数

标签 统计

c++ ×1

qt ×1

topmost ×1