PDA

View Full Version : Resizable width of vertical Header in QTableWidget



zizou2981
25th August 2016, 21:58
Hello,

I program currently a GUI with PyQt and I've created a QTableWidget where vertical and horizontal headers are visible.

My problem is currently that I can not change the width of the vertical header with the mouse. The width of the other columns can I change already.

Changeable width:
12094

Not Changeable width:
12095

My question is whether it is possible to make the width of vertical header resizable.

Thanks

anda_skoa
26th August 2016, 00:14
I don't see any vertical header, but maybe you mean the first column/section of the horizontal header?

You could try calling QHeaderView::setSectionResizeMode() for section 0.

Cheers,
_

zizou2981
26th August 2016, 01:11
@anda_skoa: the vertical Header is exists (see image) and i use this function already, but it set only the size mode of Sections and not of vertical headers.

12096

anda_skoa
26th August 2016, 12:52
You could try setting the size policy of the vertical header view so that it allows shrinking.

Cheers,
_

zizou2981
26th August 2016, 13:52
i try it but nothing has changed.

Added after 19 minutes:

My Problem is that some vertical header in my QTableWidget have a long names. So as altenative for resizable vertical header i want to set a fixed width fo the Header and make a text elided.

My Question is how can i make a text of a header elided?

Thanks

anda_skoa
26th August 2016, 14:05
Since you wrote QTableWidget, do you set header items for the vertical header?

If setting different size hint does not work, you could try setting elided texts, e.g. using QFontMetrics::elidedText().

Cheers,
_

zizou2981
26th August 2016, 14:32
Thanks for your help anda_skoa. I use now elided text with fixed header width and it works.