Qt Referencing files within code


Example

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);