Hi,
I have a QTableView bound to a QSqlTableModel.
I'm strugling to find a way to change the row (that's the vertical) headers. Is there any way to do that? And how?
A Singer
Hi,
I have a QTableView bound to a QSqlTableModel.
I'm strugling to find a way to change the row (that's the vertical) headers. Is there any way to do that? And how?
A Singer
Subclass the model and reimplement its headerData() method.
Avrohom (12th May 2009)
Thanks for your help. I've tried it, and works fine. However, when trying to return a QSize on role == Qt::SizeHintRole the application crashes.
Any suggestion?
It shouldn't crash (meaning your code is probably wrong) although returning a size hint role for the header has no effect as the size of the header is controlled by the size of the data cells.
Thanks. OK, as someone that tries to learn QT I will dig into the code to find out what I have done wrong. But how do I set the cell's width then?
Look at QHeaderView API.
Dear Wysota,
Thanks for the help. Before checking out on that api, I thought you might be interested in the following.
First, I found out what was causing my application to crash, and that was that I haven't provided a default return value i.e. for values that didn't match any of the tested scenarios in the headerData implementation.
Second, after fixing that bug, I found out that, returning a QSize value in the headerData implementation where role == Qt:SizeHintRole has definitely an effect on the cell size. So this one is also solved.
Bookmarks