PDA

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



Bong.Da.City
23rd June 2012, 10: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:

7888

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 :)

ObiWanKenobe
23rd June 2012, 12:37
QHeaderView *header = yourTableWidget->horizontalHeader();
header->setResizeMode(QHeaderView::Stretch);

Bong.Da.City
23rd June 2012, 12: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 )..

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

Bong.Da.City
24th June 2012, 15: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?

wysota
24th June 2012, 15: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.

Bong.Da.City
24th June 2012, 15: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?

wysota
24th June 2012, 16: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).