Problem with displaying picture
« on: 05 November 2015, 22:07:08 »
When I load a tgui::Picture::Ptr as part of a class from another such thing, when I try to display it in panels it only shows the very last object. Like it should show the Picture 10 times in 2 rows of 5, but it only shows the last column of the second row. Images that point to something else display properly.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Problem with displaying picture
« Reply #1 on: 05 November 2015, 22:30:59 »
I can only think of one reason why this would happen, are you reusing the same tgui::Picture::Ptr in multiple places? Because every widget can only have one parent i.e. you can't add the same picture to multiple panels. You need to copy it if you want to use it somewhere else:
tgui::Picture::Ptr pic1 = std::make_shared<tgui::Picture>("Image.png");
tgui::Picture::Ptr pic2 = tgui::Picture::copy(pic1);

If that is not the issue then you should show a minimal code example.

Re: Problem with displaying picture
« Reply #2 on: 05 November 2015, 22:37:46 »
I can only think of one reason why this would happen, are you reusing the same tgui::Picture::Ptr in multiple places? Because every widget can only have one parent i.e. you can't add the same picture to multiple panels. You need to copy it if you want to use it somewhere else:
tgui::Picture::Ptr pic1 = std::make_shared<tgui::Picture>("Image.png");
tgui::Picture::Ptr pic2 = tgui::Picture::copy(pic1);

If that is not the issue then you should show a minimal code example.

This solved the problem. The confusion appears to have resulted from the way Ptr is used in TGUI vs a standard *. Thanks for assistance.