PDA

View Full Version : adding icons from resources to buttons without Qt3Support



skyphyr
5th December 2006, 15:36
Hi All,

I've got a resource file which I've used to add icons to buttons in designer.

The problem I've hit is that the code it generates uses qPixmapFromMimeSource - which I can get to work using Qt3Support, but I'd rather have it generate Qt4 style code.

Anyone know how I can get it to do this? Or what I should be using if I put the changes into the constructor of my class which inherits this ui file?

Cheers,

Alan.

wysota
9th December 2006, 12:57
In Qt4 you should create a qrc file and use a proper URI to reach the resource from your code. What buttons are we talking about here anyway? Qt3 ones?

skyphyr
13th December 2006, 17:23
Hi wysota,

Sorry for the delay - I complete forgot I posted this for a while with other issues popping up.

The project has only been done in Qt4 and the button type is QToolButton.

I have used a .qrc file - here's an example section from the .ui file


<widget class="QToolButton" name="taskResume" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Resume Task</string>
</property>
<property name="text" >
<string>></string>
</property>
<property name="icon" >
<iconset resource="../splishgraphics/splishgraphics.qrc" >:/icons/splish_play.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>


Thanks for the help.

Cheers,

Alan.

wysota
14th December 2006, 01:15
So what is the problem?

skyphyr
24th December 2006, 13:24
The problem is that it creates code which requires qt3support, not code which is purely qt4.

Cheers,

Alan.

wysota
24th December 2006, 14:16
What exact symbols does it need from Qt3support?

skyphyr
30th December 2006, 17:11
Hi wysota,

It needs qPixmapFromMimeSource from q3mimefactory.h

Cheers,

Alan.

wysota
30th December 2006, 17:30
Can you post a small compilable example experiencing such a behaviour? Are you porting from Qt3? In the snippet you posted everything seems to be fine, the problem has to be elsewhere...

Glitch
8th January 2007, 22:51
I have run into this when porting Qt3 forms to Qt4. You should just delete the pixmapFunction (or something to that effect) tag and its contents from the .ui file by hand. Worked for me. Newly created forms should not have this problem.

--Justin

skyphyr
11th January 2007, 16:34
Hi,

Sorry again for the delay. This has definitely fixed it for me :-) I've only even worked in Qt4 for this project - perhaps I accidentally opened the ui in kdevelop's embedded designer?

Thanks very much for the help with this one.

Cheers,

Alan.