i can try using QTableView::resizeRowsToContents() but i am not sure it will work for me properly. I am drawing the text being displayed in the table rows myself in the paint() function. So, to display only 8 rows in the table at a time, i increase the font size but from where will QTableView::resizeRowsToContents() get the sizeHint? I guess it will use the default size hint. But i want to specify the size hint myself so that i can control the row height myself.
I'll try using QTableView::resizeRowsToContents() tomorrow when i work on the code.
And the most important question is that why isn't sizeHint() getting called for QTableView? Is it a known issue? I don't think it is mentioned anywhere in the Qt Documentation that sizeHint() doesn't work for QTableView, so i guess it's a bug. Even if it doesn't work, there should be atleast some way to specify the row height in QTableView.
Can you try to run the sample application code i posted and observe the difference in behavior of sizeHint() for QTableView and QListView?
My GNU/Linux Blog:
http://funwithlinux.blogspot.com
It will ask the delegate for the size hint.
Because in the default mode the headers control cell sizes, not the other way round. If you change the resize mode of the headers to ResizeToContents it will ask the contents for the size.And the most important question is that why isn't sizeHint() getting called for QTableView?
Yes, it's called a featureIs it a known issue?![]()
montylee (19th February 2009)
aah, you are right! After calling QTableView::resizeRowsToContents() sizeHint() is being called and looks like my problem is resolved
I'll test this code in my main application tomorrow.
Thanks!!! looks like once again you rescued me![]()
My GNU/Linux Blog:
http://funwithlinux.blogspot.com
ok, i am able to set the row height properly now in my main application.
So, this was not a bug i guess. But it should be mentioned in the documentation of sizeHint() that one needs to use set QTableView::resizeRowsToContents() and QTableView::resizeColumnsToContents() to use sizeHint.
My GNU/Linux Blog:
http://funwithlinux.blogspot.com
Why should the docs of the delegate contain information about a special behaviour of some other widget? The information you are looking for is there, just not in the place you were looking for it.
See QHeaderView::ResizeMode, especially the last (not counting the one in brackets) sentence from the Interactive value description and first sentence of ResizeToContents value description.
Where is resizeRowsToContents() supposed to be called when the model gets updated?
I know this is resurrecting an old thread, but I wound-up here when trying to figure out why sizeHint wasn't being called when overridden in a custom QGraphicsWidget.
Someone might wind-up here, so I'll add my discovery that having called setContentsMargins at any time before layout will solve this problem.
Bookmarks