tags:

views:

1189

answers:

3

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.

+1  A: 

I'm not too familiar with using Qt via Python, or using QMessageBox. However, a quick glance at the documentation implies that a warning would use the warning icon, which should be the platform's default icons if they haven't been changed. Have you tried looking through Qt's bug tracking system to see if it is a bug? Or submitting a bug/feature request for it?

Caleb Huitt - cjhuitt
+3  A: 

http://doc.trolltech.com/4.5/qmessagebox.html

from the above link:

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.

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.trolltech.com/4.5/qmessagebox.html#Icon-enum

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

HTH! greets

Giancarlo
+1  A: 

I am not sure how you have written your usage of the message box but here is how I use it:

from PyQt4 import QtGui
QtGui.QMessageBox.warning(parent, dialogTitle, dialogText)

If that does not produce a warning icon in your message box, then you may want to consider upgrading your PyQt to the latest version, because I have experienced small bugs like this in the past with some PyQt revisions.

Chris Cameron
I did, just today... there's probably some library for the icons that I don't have installed. Please don't worry about it too much unless you already know (or are a qt dev); it's not so much of an issue for me. cheers, Nicholas
gatoatigrado