View Full Version : QTableWidget do not hide headers on resize, what to do?

23rd June 2012, 11:42
Hello Qt community!
I have a QTableWidget and I don’t want its headers to resize forever.
I know that I can hide the scrollbar, but this still doesn’t solve my problem.
Let’s say that I have 3 headers in my QTableWidget, named “One”, “Two” and “Three”. I want to be able to resize each of these headers without the text of the others to be hidden. So, basically I need a minimum ‘resize rate’, which has to be set to the width that the text of each header captures.

Sorry if I am not fully understandable.
Here are an example screenshot of what I don’t want to happen:


As you see, I’ve resized “Two”, but the text of “Three” has been hidden, and I’ve turned scrollbars off. I want to be able to resize each header (column) till the point of not hiding the text of the other headers.

Thanks in advance for any help :)

23rd June 2012, 13:37
QHeaderView *header = yourTableWidget->horizontalHeader();

23rd June 2012, 13:49
Thanks for the answer but this ones disables the Resizing..
We want to be able to resize columns but if u resize the one before the last one don't continue resizing as much as u want ( see previous screenshot )..

24th June 2012, 03:34
What do you expect to happen when the user resizes the whole window?

24th June 2012, 16:14
What should i expect? Tablewidget becomes bigger, and collumns become bigger..
Why question this.. this has nothing to do with my question ( i think )

Do you understand what i ask?

24th June 2012, 16:33
Why question this.. this has nothing to do with my question ( i think )
It has a lot to do with your question. Especially the behaviour you want when the window is resized down.

24th June 2012, 16:50
OK Think for now, let's says i have maximum and minimum to window and i can't resize it..

How to do what i say in 1st post?

24th June 2012, 17:39
Then you need to control resizing of the header manually either by reimplementing some virtual methods in QHeaderView subclass or by connecting to QHeaderView::sectionResized() signal (or both).