如何在qt中使用默认图标 [英] how to use default icons with qt

查看:109
本文介绍了如何在qt中使用默认图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只使用 Qt(虽然是 PyQt),当我打电话时我没有得到图标,例如QMessageBox.warning().有没有办法使用平台的默认图标?目前我正在使用更完整的 QMessageBox 构造函数并调用 setIconPixmap.

I'm using only Qt (though PyQt) and I don't get icons when I call e.g. QMessageBox.warning(). Is there a way to use the platform's default icons? Currently I'm using the more complete QMessageBox constructor and calling setIconPixmap.

推荐答案

http://doc.qt.io/qt-5/qmessagebox.html

来自上面的链接:

QMessageBox 支持四种预定义的消息严重性级别或消息类型,它们实际上仅在它们各自显示的预定义图标上有所不同.通过将 icon 属性设置为预定义的图标之一,指定四种预定义的消息类型之一.

QMessageBox supports four predefined message severity levels, or message types, which really only differ in the predefined icon they each show. Specify one of the four predefined message types by setting the icon property to one of the predefined Icons.

所以你应该使用 QMessageBox 构造函数:

so you should use the QMessageBox constructor:

QMessageBox ( Icon icon, const QString & title, const QString & text, StandardButtons buttons = NoButton, QWidget * parent = 0, Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint )

并且您可以使用以下图标之一:

and you can use one of these icons:

http://doc.qt.io/qt-5/qmessagebox.html#Icon-enum

例如你可以为图标传递这个参数:QMessageBox::Warning

for example you can pass this parameter for icon: QMessageBox::Warning

哈!问候

这篇关于如何在qt中使用默认图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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