tuli
7th October 2013, 11:01
I have a separate widget consisting of a QTextEdit and a few buttons. The QTextEdit has a preferred size and grows as the widget is resized. All of this works fine.
however, when i want to set this widget into the cell of a QTableWidget, using tw->setCellWidget(a,b,mywid), then my widget is much bigger than its preferred size.
for(...rows...)
for(...cells...)
tablewidget->setCellWidget(row, cell, new mywid());
tablewid->resizeColumnsToContents();
tablewid->resizeRowsToContents();
I can then proceed to manually resize the column width, which shrinks my widget accordingly.
The question is, why doesnt setCellWidget() respect my wished size?
mywidget->show()
pops up the widget, sized correctly.
edit:
no, i was wrong: sizeHint() returns an incorrect size! Why is that? Why is it show()n sized correctly?
however, when i want to set this widget into the cell of a QTableWidget, using tw->setCellWidget(a,b,mywid), then my widget is much bigger than its preferred size.
for(...rows...)
for(...cells...)
tablewidget->setCellWidget(row, cell, new mywid());
tablewid->resizeColumnsToContents();
tablewid->resizeRowsToContents();
I can then proceed to manually resize the column width, which shrinks my widget accordingly.
The question is, why doesnt setCellWidget() respect my wished size?
mywidget->show()
pops up the widget, sized correctly.
edit:
no, i was wrong: sizeHint() returns an incorrect size! Why is that? Why is it show()n sized correctly?