Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Custom QHeaderView header size problem
I'm trying to subclass QHeaderView to add some behavior i need (context menu with column to show/hide, add a lineEdit in the header to filter columns ...)
My header is added to a QTreeView with setHeader function.
My problem is that sections can be resized to a smaller size than the text in the header section. How can i force a minimum size column by column, depending on the header text ?
Hi and welcome to devnet,
Did you try the minimumSectionSize property ?
Hi ! And thanks ;)
yes i've tried minimumSectionSize and it worked well for all columns.
By the way i need to manage columns size independently as text in headers are all differents...
For information i'm stuck with Qt 4.7
I managed to find a way but i think it's ugly.
When sectionResized() signal is raised, i manually check if new section size is lower than minimal size i want for the section.
If not i manually call resizeSection() on the section with my minimal size.
What about sectionSizeHint ?
same thing, sizeHint is just a recommended size. It does not limit the minimal size.
Right, well, currently I can't see a better way than your workaround. Are you stuck with a precompiled version of Qt ? If not you could have a look and try to back port the handling you need