PDA

View Full Version : Qt5.7/C++ - Window icon shows, can't show control icons.



jimbo
3rd September 2016, 19:14
Hello,

Windows 10 32 bit
Qt5.7, QtCreator 4.1.0

I can get the QMainWindow showing an icon.

Pro file
RESOURCES += gui_icons.qrc
RC_ICONS = myApp.ico
gui_icons.qrc
<RCC>
<qresource prefix="/images">
<file>images/browse.ico</file>
<file>images/myApp.ico</file>
</qresource>
</RCC>
I have a QToolButton on the QMainWindow generated from Designer.
I have in my source code:-

ui->tbBrowse->setIcon(QIcon ("browse.ico"));I've also set the icon in Designer.
The icon never shows.
What steps am I missing?

Regards

anda_skoa
3rd September 2016, 22:13
A resource path starts with ":" and your path is also missing the "images" prefix.

Cheers,
_

jimbo
4th September 2016, 11:05
Hello anda_skoa


ui->tbBrowse->setIcon(QIcon (":/images/images/browse.ico"));Does the trick, Thanks.

Regards