我的Qt5应用程序如何以编程方式知道哪些窗口和对话框正在运行
How can my Qt5 app know programmatically what windows and dialogs are running?
我需要以编程方式知道什么窗口/对话框/小部件是打开的,因为我使用FileOpenEvent
来加载文件,如果我的QMainWindow
是唯一打开的,我只想加载文件。
我发现遍历所有QWindow
s并检查isExposed() == true
多个处理我正在做的一切,除了本机Mac对话框(另存为,打印和打开文件)。因此,这似乎足以满足我的需求:
bool found_exposed_window = false;
foreach (QWindow *window, qApp->allWindows()) {
if (window->isExposed()) {
if (found_exposed_window) {
// This is the second exposed window, meaning the user has something
// open in addition to the main form.
// So, don't try to load a file.
return;
}
found_exposed_window = true;
}
}
相关文章:
- 如何检测窗口当前是否正在运行模式对话框?
- 在主窗口之前显示登录对话框并隐藏主窗口按钮
- 找不到没有具有类名 #32770 的窗口名称的父窗口的子窗口(对话框)
- 如何在主窗口标签的对话框中显示QLineEdit的输入
- C# - 显示对话框将所有者设置为非托管窗口
- Qt从主窗口打开对话框
- wxWidgets - 阻止 OS X 上的窗口模式对话框
- 有没有办法知道父窗口的类型(基于框架或对话框)?
- 如何以编程方式更改基于对话框的窗口的大小和位置?
- 模型对话框移动到主窗口后面的Qt错误
- CMFCButton在分层窗口的子对话框中未单击
- Qt - 创建主窗口前的非模态对话框
- 如何将信号从主窗口连接到对话框中的插槽
- 窗口对话框未打开
- 窗口/对话框过程可以在名称空间中吗
- Qt更改窗口内容/常规Qt窗口/对话框
- 如何使用activex控件在窗口/对话框中呈现html文件
- 一个基于c++窗口对话框的程序如何获取系统的一个状态
- 添加水平滚动条来调整窗口对话框的大小
- 有关所需窗口对话框资源类型的帮助