QHeaderView and autoResizeToContent
I have a QTableView. And I use following code:
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 ?
Re: QHeaderView and autoResizeToContent
By reading the documentation for QHeaderView.
Re: QHeaderView and autoResizeToContent
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.
Re: QHeaderView and autoResizeToContent
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 ?
Re: QHeaderView and autoResizeToContent
Quote:
Originally Posted by
vhptt
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.
Re: QHeaderView and autoResizeToContent
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).