PDA

View Full Version : [duplicate] Qt stock items ?



JeromeQt
21st March 2014, 09:41
Hi all.

Are there stock items in Qt, such as those provided by GTK ?

http://pygtk.org/docs/pygtk/gtk-stock-items.html

For instance, to create a OK buttons, setting the OK stock item sets the right themable icon in the button, along with a localized text.

I can't seem to find anything equivalent in Qt.

Thanks in advance.

Edit: Sorry, I found a few leads after posting. Marking as duplicate.

http://www.qtcentre.org/threads/17965-Stock-Icons
http://www.qtcentre.org/threads/31910-Standard-buttons-icons
http://doc.qt.digia.com/4.6/qdialogbuttonbox.html

I'm using a buttonbox. Apparently, it is localized. Although I don't see how to set icons.

anda_skoa
21st March 2014, 10:37
The buttons have icons set if that is what the current theme is supposed to do.

If you want to override icons, you can get each button using the QDialogButtonBox::button() method.

Cheers,
_

Lesiok
21st March 2014, 10:52
Use this stylesheet : QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 1; }

JeromeQt
21st March 2014, 11:11
Thanks !

Apparently my theme (default Xfce theme on Debian and default on Windows 7 ) does not use icons, and using the stylesheet adds them.

In QtDesigner, the locale of the buttonbox is set to French as default. The locale of my system is also French (fr_FR.UTF-8). However, the buttons are displayed in english.

anda_skoa
21st March 2014, 14:34
Maybe try to explicitly load the Qt translations.
See the code example a bit down from here http://qt-project.org/doc/qt-4.8/internationalization.html#produce-translations

Cheers,
_

JeromeQt
24th March 2014, 00:36
Thanks, I'll have a look. If I'm stuck, I'll create a dedicated thread.

ChrisW67
24th March 2014, 01:06
The available stock icons can be accessed directly through QStyle::standardIcon() and the StandardPixmap enum. You can apply these images to any button or other place taking an icon in code but not from Designer. The QDialogButtonBox draws from these for OK, Cancel etc. They are provided by the style, so there is no one set of images.