Qt Resource System

Other topics

Referencing files within code

Let's say that inside a resources file, you had a file called /icons/ok.png

The full url of this file within code is qrc:/icons/ok.png. In most cases, this can be shortened to :/icons/ok.png

For example, if you wanted to create a QIcon and set it as the icon of a button from that file, you could use

QIcon icon(":/icons/ok.png"); //Alternatively use qrc:/icons/ok.png
ui->pushButton->setIcon(icon);

Contributors

Topic Id: 8776

Example Ids: 27355

This site is not affiliated with any of the contributors.