Solved QTableView::resizeRowsToContents() problem
-
Hello!
I have a function that loads data in a QTableView. I call this function from the constructor and after that, I call to "resizeRowsToContents()" but it doesn't work and shows the rows very wide. When I call resizeRowsToContents() function with a QPushButton event, for example, it works fine.
I think it is because of I am calling it in the constructor. I tried using QTableView::repaint() and QTableView::update() without success.
What can I do to fix it?
Thank you very much!
-
@ivanicy
It needs to be called from https://doc.qt.io/qt-5/qwidget.html#showEvent rather than constructor. -
@JonB Thank you very much!! It works perfectly!
-
@ivanicy
Up to you, but if you allow the containing window to be resized such that theQTableView
changes size, you might want to call it from aresize
event too.