PDA

View Full Version : Replacing One image with another



merry
8th February 2007, 09:08
Hi all

I am working on Qt3.1(Red HAt Linux).I m having a Tree Structure of various Files and Folders.Files and Folders both are represented by different different images.
Now what I want is That When I Click on a Particular File or Folder Having different images is being replaced by another images.

Foreg.

Files->representedby->image1
Folders->representedby->image2

Now when I select a Particular File
i.e When I Click on FileItem then image1 Can be Replaced By any another image say image3.

same for folders

Now when I select a Particular Folder
i.e When I Click on Folder then image2 Can be Replaced By any another image say image4

Please do reply with example.

Cheers
Merry

wysota
8th February 2007, 11:09
Use a signal-slot connection and replace the pixmap with another one.

merry
8th February 2007, 11:23
Thanx 4 ur reply But is there any other alternative .

wysota
8th February 2007, 11:46
Any alternative to what? You can always just... do nothing :)

merry
8th February 2007, 12:19
OhThanx for telling Me That i just do nothing and From now I wont ask for ur help Ok:o

wysota
8th February 2007, 12:50
You asked for help, you were given help. I gave you the simplest solution possible and you didn't like it. Without more information I won't give you another solution as I don't know what is wrong with the first one I gave.

Basically you do something by calling respective methods from classes handling the component you use and the way to change the image displayed is to call a method for... changing the image which is called setPixmap(). If you don't want to use it, then simply subclass and implement your own painting based on whatever you like.

I take it that we're talking about QListViewItems, so you have a signal which is emitted when en entry is clicked and you have a method to call to set a new image. What more do you want?

merry
8th February 2007, 14:22
Sorry , Yaa Its My fault that I wont explained you properly what i want.