ipkiss
7th November 2012, 16:06
Hi,
I am trying to have the text on a horizontal header displayed vertically (i.e. rotated 90°).
I tried the implementation given here (http://qt-project.org/faq/answer/how_can_i_display_vertical_text_in_the_section_of_ a_qheaderview), but there are several issues. Here they are, ordered by increasing gravity:
The vertical header is modified, not the horizontal one. This bug is easy to fix, we just need to replace line 12 with:
if (!hv || hv->orientation() != Qt::Horizontal)
Even though I tried applying my new style only to a particular table (myTable->setStyle(myProxyStyle)), all the tables in the application are modified. How can I avoid that?
Last but not least, the height of the horizontal header is not adjusted to take into account the size of the label. As a result, the text is truncated (and thus mostly useless). I tried two approaches to solve this problem:
override QProxyStyle::sizeForContents(). I expected that it would be called for ContentsType CT_HeaderSection, but unfortunately it is not (it is however called for each view item, which doesn't help).
override QProxyStyle::subControlRect(). I hoped that it would be called for SubControl SE_HeaderLabel, but it is not.
Does anyone have a suggestion about how to solve this problem?
Note: I'm using Qt 4.8.
I am trying to have the text on a horizontal header displayed vertically (i.e. rotated 90°).
I tried the implementation given here (http://qt-project.org/faq/answer/how_can_i_display_vertical_text_in_the_section_of_ a_qheaderview), but there are several issues. Here they are, ordered by increasing gravity:
The vertical header is modified, not the horizontal one. This bug is easy to fix, we just need to replace line 12 with:
if (!hv || hv->orientation() != Qt::Horizontal)
Even though I tried applying my new style only to a particular table (myTable->setStyle(myProxyStyle)), all the tables in the application are modified. How can I avoid that?
Last but not least, the height of the horizontal header is not adjusted to take into account the size of the label. As a result, the text is truncated (and thus mostly useless). I tried two approaches to solve this problem:
override QProxyStyle::sizeForContents(). I expected that it would be called for ContentsType CT_HeaderSection, but unfortunately it is not (it is however called for each view item, which doesn't help).
override QProxyStyle::subControlRect(). I hoped that it would be called for SubControl SE_HeaderLabel, but it is not.
Does anyone have a suggestion about how to solve this problem?
Note: I'm using Qt 4.8.