PDA

View Full Version : QToolButton icon did not appear



mismael85
23rd March 2008, 21:05
hi,
i am using QToolButton to QFileDialog::getOpenFileName so i
used the following function to set the button icon

browseButton->setIcon(QIcon(":/images/open.png"));
and i added the file entry in the resource file

<file>images/open.png</file>
but, the icon did not appear
what should i do?

jpn
24th March 2008, 14:31
Is ":/images/open.png" listed when you do:


QDirIterator it(":", QDirIterator::Subdirectories);
while (it.hasNext())
qDebug() << it.next();

?

mismael85
24th March 2008, 17:40
thank you i did it and i found that the directories listed was
:/dialog/images/open.png
so i added /dialog to the
QToolButton::setIcon
and it works fine
but why the /dialog added however there is no directory called dialog in my project?

jpn
24th March 2008, 17:48
Notice the prefix-attribute of qresource-element:


<qresource prefix="/dialog">
...
<file>images/open.png</file>
...
</qresource>

Does your resource file look like this?

mismael85
24th March 2008, 18:13
exactly , so i deleted the (prefix="/dialog") from my resource file and every thing works fine now .
thank you.