Change picture on button click


I have an application with initial picture set using this code:

When I click on button, I want to swap a picture1.jpg to picture2.jpg. I have tried several things but nothing seems to work.
Also, there is a protected function Redraw() but I don’t want to inherit the class TGIcon so I can use it. Is there any other way I can use Redraw() function? Or is there any other away to change a picture on screen by pressing a button?

PS: I have tried using TImage, and it doesn’t fit in my application.

Thank you!


You can take a look at the RootShower demo application in $ROOTSYS/test/RootShower. And more precisely at GTitleFrame.cxx:

gClient->FreePicture(fRightIconPicture); fRightIconPicture = (TGPicture *)gClient->GetPicture(theRightLogoFilename); fRightIcon->SetPicture(fRightIconPicture);
Cheers, Bertrand.

It worked on the first try!

:smiley: :smiley: :smiley:

Thank you!!