开发者

finding the top-level widget on a non-activewindow in qt

I'm trying to find the top-level widget on a non-active window. But开发者_运维知识库 I do not want to use QApplication::topLevelAt() method. I have a main window and several child widget's of main window's central widget. Is it possible to distinguish whether one of the child widget is on top of other childs?

Sami


QObject::children() lists the children of a given object. For QWidgets, the children are drawn in order of the list, which means that you can get the top-most (last-drawn) child with the following code:

QWidget *topmost_p = qobject_cast<QWidget*>(parent_p->children().last());

Be aware that the above code may fail if the parent has no children.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜