Project

General

Profile

WTableView insert WContainer in cell

Added by Sanders Yeh about 7 years ago

Hi,

I am trying to show an overlaid image inside a cell of WTableView.

I store my images in a WContainer and overlay them.

However, when I use "setData()" to insert it into WStandardItemModel, it doesn't show anything with the TableView.

  WContainerWidget* container = new WContainerWidget();
  container->setPositionScheme(Relative);
  WImage* img = new WImage(WLink("icons/Warning.png"), container);
  img->setPopup(true);
  img->setPositionScheme(Absolute);
  img->resize(100,100);
  WImage* img2 = new WImage(WLink("icons/Rescheduling.png"), container);
  img2->setPositionScheme(Absolute);
  img2->resize(300,300);

  WStandardItemModel* model = new WStandardItemModel();
  model->setData(0, 0, container);

  WTableView* table = new WTableView();
  table ->setModel(model);

Do I need to create a custom delegate?

If needed, could I have some example of how to override WItemDelegate for container.

Any advice or guidance would be greatly appreciated.


Replies (3)

RE: WTableView insert WContainer in cell - Added by Sanders Yeh about 7 years ago

Found it !

Just override WItemDelegate for a container.

RE: WTableView insert WContainer in cell - Added by Roel Standaert about 7 years ago

Yes, the default WItemDelegate will simply try to display the data as a string.

You'd have to create your own item delegate implementation, or if you can do it with CSS, it may be simpler to use a style class (with StyleClassRole).

Regards,

Roel

RE: WTableView insert WContainer in cell - Added by Sanders Yeh about 7 years ago

Thank you for your reply.

    (1-3/3)