在 PyQt 中为 mac 创建消息框作为工作表 [英] creating message box as sheets for mac in PyQt

查看:42
本文介绍了在 PyQt 中为 mac 创建消息框作为工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用消息框作为单独的对话框而不是 mac OS 的工作表,现在我正在研究它以生成一个工作表作为消息框而不是单独的一个.

I used message box as seperate dialog instead of sheets for mac OS, now i m working on it to spawn a sheet as message box instead of seperate one.

我尝试将消息框设置为模态框:

I have tried setting the message box as a modal one:

(messagebox.setWindowModality(QtCore.Qt.WindowModal))

并设置消息框,父对话框窗口标记为工作表

and setting message box, parent dialog window flags as sheet

(parentDialog.setWindowFlags(QtCore.Qt.Sheet) messagebox.setWindowFlags(QtCore.Qt.Sheet))

但上述命令无法创建工作表而不是单独的对话框.

But the above commands are not working to create a sheet instead of seperate dialog.

有人知道如何解决吗?

推荐答案

对话框不能显示为带有 exec_() 的工作表.

A dialog cannot be shown as a sheet with exec_().

相反,只需使用 QMessageBox.open(),其中,在 Mac 上,大致相当于:

Instead, simply use QMessageBox.open(), which, on a Mac, is roughly equivalent to:

messagebox.finished.connect(self.handler)
messagebox.setWindowModality(QtCore.Qt.WindowModal)
messagebox.setParent(messagebox.parentWidget(), QtCore.Qt.Sheet)
messagebox.setResult(0)
messagebox.show()

这篇关于在 PyQt 中为 mac 创建消息框作为工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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