如何将小部件带入Qt中? [英] How to Bring the Widget Bring to front in Qt?

查看:69
本文介绍了如何将小部件带入Qt中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看以下屏幕截图:

圆圈是自定义控件。单击控件时,需要将小部件置于最前面。例如如果我单击第二个圆圈,则它应如下所示:

The circles are custom controls. When I click a control, I need to bring the widget to the front. Ex. if I click the second circle it should look like this:

单击控件时,我可以获取发件人(即控件)。唯一的问题就是如何将对象放在最前面。

When the control is clicked I am able to get the sender (i.e. the control). Only thing is how to bring the object to the front.

请帮助我解决此问题。

推荐答案

您是否尝试过 QWidget :: raise()


将此小部件提高到父小部件堆栈的顶部。调用之后,该窗口小部件将在视觉上位于任何重叠的同级窗口小部件的前面。

注意:使用activateWindow()时,可以调用此函数以确保窗口堆叠在顶部。

Raises this widget to the top of the parent widget's stack. After this call the widget will be visually in front of any overlapping sibling widgets.
Note: When using activateWindow(), you can call this function to ensure that the window is stacked on top.

所以我通常使用的模式将确保显示一个窗口,将其显示在同级小部件的前面,并在其他应用程序的前面: / p>

So the pattern I usually use that will ensure a window is shown, brought to the front of sibling widgets and brought in front of other applications is:

widget->show();
widget->activateWindow();
widget->raise();

这篇关于如何将小部件带入Qt中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆