简体   繁体   中英

Wrap header titles in QTableWidget

I have a QTableView with a QHeaderView set.

I would like to set wordwrap on the header content (QString), but not the table content. Is this possible?

It is dynamic data, so I am not able to use \\n in my strings. The columns of my list have a fixed width.

I don't see any wordwrap for this object any where here: http://qt-project.org/doc/qt-4.8/qheaderview.html

I see the question was posted before, but with no useful answers: How to set header titles to wrap in QTableWidget

Thanks in advance !

I did it on this way (this method expects using the Qt Designer):

  • throw a QTableWidget into your MainWindow or form

  • double click the TableWidget

  • enter your headings

  • click the button "properties" in the bottom right corner

  • adjust whatever you want

As far as I understood your question, this is the way I did it. Hope it helped you and sorry for my bad english. :)

edit: try tableWidget->setwordWrap(true)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM