Resizing Not Visible Columns



  • Hello I have a TreeView with about 20 Columns. I have implemented a context menu to be able to show or hide each column. However when I show new columns they are very small and I have to resize them manually. I'd like to be able to do this in code. I've tried resizeSection() and resizeColumnToContents(). These functions don't seem to work unless there is visible space for the columns to be added.

    I want to show the new columns and be able to resize the column even though it's not being shown. This was a user can scroll over and see the new column without resizing it.

    Can anyone help? This seems like a simple problem, but I can't figure it out.

    ANSWER:

    Well this took forever to find but here's something that worked for me. Hopefully this can help someone in the future.

    Turns out the headerview has a setMinimumSectionSize function. This was sufficient for my purposes. It will make the column a minimum of a fixed width (passed in to the function).


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.