How to get Qt icon (QIcon) given a file extension
问题 I am developing an application that needs to display icons associated with different file types . Eg for .doc extensions, i need it to be able to display the Microsoft Word icon . QUESTION: How can I somehow get a QIcon from the system using QT sdk Thanks. 回答1: Use the QtGui.QFileIconProvider class. 回答2: Since Qt5, use QMimeDatabase for that: QMimeDatabase mime_database; QIcon icon_for_filename(const QString &filename) { QIcon icon; QList<QMimeType> mime_types = mime_database