1

I need a QWidget to use (occupy, fill) an entire row in a QTreeview with several columns, but I can't find any clues on how to do such thing neither in the docs or the web. I guess this is not a super strange scenario, so it should be rather easy(?). I hope so.

Thanks in advance!

EDIT:

Btw, the idea behind this is to mark rows as "deleted" instead of just removing them from the view. I want the original content of the row cells to stay where it was before the deletion, obscure the row and show a semi-translucent label or image on top of the entire row saying "CONTENT DELETED" or something like that.

Guillermo Ares
  • 197
  • 1
  • 12
  • How does that widget use the the row from QTreeView? – Alexander V Aug 05 '16 at 03:37
  • Hi! I'm sorry, I messed up the words. I want the widget to be displayed all over the row, but I can only use setWidgetIndex on a cell. So I'm only able to display the widget over one cell. Sorry if I'm not being completely clear, English's not my natural language :/ – Guillermo Ares Aug 05 '16 at 03:42
  • Try to attach the picture with UI design you want. – Alexander V Aug 05 '16 at 04:06
  • You mean with a stylesheet? Didn't know that could be done. I'll give it a try tomorrow (it's 1 am here). Thanks! – Guillermo Ares Aug 05 '16 at 04:11
  • png or gif or jpeg with picture. – Alexander V Aug 05 '16 at 06:26
  • Did you try [`QTreeView::setFirstColumnSpanned`](http://doc.qt.io/qt-5/qtreeview.html#setFirstColumnSpanned)? – thuga Aug 05 '16 at 07:32
  • @AlexanderVX, I tried with the stylesheet, but I need the image to be in the horizontal center of the row. I tried using QTreeView::item, but that draws the image over each cell instead of drawing it once. I also tried using ::branch, but didn't work at all (the image was not drawn). Am I missing something? – Guillermo Ares Aug 05 '16 at 21:49
  • @thuga: The problem with that function is that I want the original content of the cells to be still visible when I put my widget/image on top of the row. `QTreeView::setFirstColumnSpanned` would mess all the data displayed in the cells. – Guillermo Ares Aug 05 '16 at 21:53
  • @GuillermoAres, nothing comes to mind except overriding the draw event: http://stackoverflow.com/questions/26847538/draw-focus-for-row-in-qtreeview You will need to override the pain event for row delegate for tree view: http://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForRow QTreeView::setItemDelegate can be used for that. – Alexander V Aug 06 '16 at 06:43
  • @AlexanderVX Yeah, I don't see any other way :/. I'll try it out on Monday and come back to you when it's working. Thanks a lot! – Guillermo Ares Aug 08 '16 at 19:08

0 Answers0