2

I try to insert a custom widget into a QTableWidget using the setCellWidget function

void QTableWidget::setCellWidget ( int row, int column, QWidget * widget )

My problem is now, that the paint method of the custom widget isn't called. Anyone knows why?

Best regards

pnezis
  • 12,023
  • 2
  • 38
  • 38
  • Is it called, when you add you widget just to form (QWidget)? – Lol4t0 Jan 10 '12 at 13:05
  • I just saw that the paint function is called indeed. But i can't paint. It says: "paint returned engine = 0". Also a label, which is placed inside the custom widget, is not there. – user1037319 Jan 10 '12 at 14:04
  • First check that you widget work properly outside `QTableWidget`. You cannot be sure that your problem is connected with `QTableWidget` until you check whether your widget work outside it. – Lol4t0 Jan 10 '12 at 14:13
  • It's working properly outside QTableWidget. I made some more tests. My custom widgets is made out of several outer custom widgets. The paint method of the first widget, which holds all the others, is called. But the paint methods of the other custom widgets are not called. Outside QTabelWidget everythings works fine. – user1037319 Jan 10 '12 at 14:28
  • Ok i can paint lines with QPainter. But the background color of the custom widget is ignored. – user1037319 Jan 10 '12 at 14:47
  • How did you set the background color (stylesheet, palette...) ? Does the custom widget inherit **directly** from QWidget ? – alexisdm Jan 10 '12 at 14:55
  • Did you try setAutofillBackground(true) on your widget? By default, widgets do not fill the background automatically unless this option is set. – galinette Sep 12 '13 at 10:08
  • 1
    Provide an example of the problem that we can reproduce it. – Protomen Oct 19 '14 at 14:38

0 Answers0