Unsolved After changing header height, how to fix problem in table rows
-
Hi all,
I have a problem.
There are 2 tableviews and they are splitted from each other with a splitter.
One of the table's (table A) header has a header row with \n character. So that, its height is doubled. But in other table (table B) I have only single line header names.
The thing I want to do is , I want to resize the header of table B according to the height of table A.
However, when I use resize() method or even reimplementing painevent(), there will be a problem.
Table B's height becomes like table A's size. However, the content of the tableview still positioned in the same place like before resizing table B's header height. It means that the first row of the tableview B is still in the same position, not repositioned according to new header height. How can I fix this?
-
@DzCode said in After changing header height, how to fix problem in table rows:
However, when I use resize() method or even reimplementing painevent(), there will be a problem.
Since you say you are having a problem with this not working right, if you do not get any better, specific answers here for how to accomplish this would the best thing be to (try) making one of the header texts in table B have an extra
\n
at the end of it, so that way it will be working the same way as in table A? -
no this is just a cheating.
It is not a good idea to update all column headers in a big dataset. There are so many views using same models
-
@DzCode
I don't think it's "cheating" :) And you will have to know somehow that the height of column A has changed in order to know you need to adjust column B.However, what about subclassing
QHeaderView
and overridesizeHint()
to return the desired height in B from the height in A? This is illustrated in the answer at https://stackoverflow.com/questions/11314566/how-to-set-height-of-horizontal-header-qheaderview . -
@JonB I dideverythig I can do.
I reimplemented sizehint, paintevent or any other. All of them does not solve.
Maybe you can understand the problem now. (Also, the sizes can change dynamically, so that it is not good to change sizehint event)
-
@DzCode
I don't know. There is no "sizehint event". All I can say is from the link I showed you the question reads:I need adjust headers of two tables, standing near each other, because headers have different lines of text. It seems impossible.
Which seems to be exactly what you are asking for. Posts elsewhere for the same question also say to do it the same way, by returning the desired value for
MyCustomHeaderView::sizeHint()
.Best of luck.
-
@JonB yes I will ask on another platforms
By the way, I should have use the same QHeaderView subclass for both of the table since I have implemented drag and drop between these tables via usign the header