PDA

View Full Version : QHeaderView and autoResizeToContent



vhptt
17th August 2012, 10:14
I have a QTableView. And I use following code:

ui->tblCivilianFlightPlan->setModel (mModel);
ui->tblCivilianFlightPlan->resizeColumnsToContents();
ui->tblCivilianFlightPlan->horizontalHeader()->setStretchLastSection(true);

Content of header display ok. But I use multi-language for my app, and when I switch language, the content doesn't show completely.
How can I make the header auto resizing to content ?

yeye_olive
17th August 2012, 10:22
By reading the documentation for QHeaderView.

maximebd
17th August 2012, 16:50
You have two choices. Like yeye_olive said, if you had read the documentation for QHeaderView, you would know that you can set QHeaderView::setResizeMode(QHeaderView::ResizeToCo ntents) to automatically resize for you. But if you do that you can't change the size of the columns to whatever you want. So what I would do is to re-call resizeColumnsToCentents() after you have processed the QEvent::LanguageChange event.

vhptt
18th August 2012, 11:08
I'd read the document and I know QHeaderView::setResizeMode() but I dont like it 'cause I cant change the size of the columns.
So, re-call resizeColumnsToContent() may be a better way.
But, problem is: I cant find the thing resizeColumnsToContent() in document QHeaderView (and QAbstractItemView). How can I find this ?

yeye_olive
20th August 2012, 15:29
But, problem is: I cant find the thing resizeColumnsToContent() in document QHeaderView (and QAbstractItemView). How can I find this ?
You have got to be kidding us; just read your first post above.

Note that this will resize all columns, not just those which are not large enough.

vhptt
22nd August 2012, 07:56
I'm not kidding. Maybe this is a stupid question, so plz help me.
Did you mean " just read your first post above." about: ui->tblCivilianFlightPlan->resizeColumnsToContents(); ???
But, My question is about function resizeColumnsToContent() of QHeaderView, not for QTableView. Or I'm using wrong word about size of section of header (my english is not good :) ).
In addition, I have trouble with tab size - QTabWidget too T___T (after switching language, tabwidget does not show completely tabText).