Important: Please read the Qt Code of Conduct -

How to make QTableView to adjust the height of it's horizontal header automatically in PyQt?

  • The thing is I have long sting for header, typically from 4 characters to somewhere 100 characters but the header is dynamic.

    I found that we can make the header wrap using default alignments as Qt.AlignCenter | Qt.Alignment(Qt.TextWordWrap), however it does not make the horizontal height auto adjust based on the contents, I have some initial widths for each of the column. Is there a way to make the header heights auto adjustable whenever a column is resized?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    100 chars for a header ? That seems a bit excessive. Can you explain your use case ?

Log in to reply