PDA

View Full Version : Secont ToolBar with Icon



RodFromGermany
20th April 2012, 10:08
Hallo Forum,

I am new in Qt and I have a Question in Designing a GUI in Qt 4.7.1.
We have a "Standard GUI" with a ToolBar with a lot of Icons, listed in the file
gui/res/images.qrc
In a special "Service Mode" we create a second Toolbar which is added while Runtime, those icons are listed an other folder in the file
gui-service/res/images.qrc
Problem: The Service Action works well, but there icons are serched in the "Standard Path".
How it is possible to get access to the icons listed in the file app-gui.service/res/images.qrc?

Thank You.

^NyAw^
20th April 2012, 12:40
Hi,

Try this:


QIcon qIcon(":/myResource/icon1.png");


Note that ":" points to the resource file.

RodFromGermany
20th April 2012, 14:05
Thanks.

Sorry, mistake of me.:(
The other file gui-service/res/images.qrc is not a part of the "normal GUI" ui-File.
At first we had a second Service-GUI.ui file.
Now our ServiceGui class is subclassed from the normal GUI class, so the qrc file is stand allown.

Rod

Rhayader
21st April 2012, 11:19
You can use the static function QResource::registerResource
after you have used rcc on the .qrc file

More info on http://qt-project.org/doc/qt-4.8/resources.html

RodFromGermany
23rd April 2012, 08:25
@Rhayader: Thank You, the link was precise, now it works perfect.