How to change the Qt application dock icon at run time on MacOS?

I need to change my Qt application app icon (on MacOS X) at runtime according to some conditions.

I found some recipes on trolltech.com :

  • QApplication::setIcon()
  • setApplicationIcon()
  • qt_mac_set_app_icon()

but none of them work: there are no such methods / functions in Qt 4.5.

How can I change the application icon for the dock and what icon formats to use?

Thanks.

+4
source share
1 answer

In Qt 4.5, the methods you are looking for are called

 QApplication::setWindowIcon(const QIcon &) 

or

 QWidget::setWindowIcon(const QIcon &). 

You can use each image format for the icons supported by Qt (e.g. BMP, GIF, JPG, PNG, TIFF, XPM, ...).

You might want to see the Qt documentation at http://doc.qtsoftware.com/4.5/index.html or use the Qt Assistant.

Hope this helps.

+8
source

Source: https://habr.com/ru/post/1286072/


All Articles