Python Forum

Full Version: QTreeView, StyleSheet resizes last column
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using a QTreeView with a StyleSheet set to it. This tree has checkboxes, and the style replaces the image for the empty, checked and partially checked boxes. My issue is, when I set the StyleSheet, the last column/section is stretched beyond what I set it to (I manually set section/column sizes via tree.setColumnWidth(). I've also tried header.resizeSection()). Without the StyleSheet, everything works as intended.

I'm not going to share code (I know that will limit any help) because 1) it's split up over multiple modules, and 2) I believe it to be buggy type behavior within StyleSheets (I read StyleSheets are kinda buggy). If it is buggy behavior, is there a workaround?

Currently, I have my app working the way I want by setting the layout's size (QGridLayout: column width) that houses the QTreeView. This question is more for academic purposes—can it be fixed via StyleSheets or something else?

I've tried QTreeView::section:last{width: 110;}, QTreeView::section:last{max-width: 110;}, and header.setMaximumSectionSize(110). Any ideas?
Without code it will be hard for anyone to help. You could try setColumnStretch()
(Sep-15-2023, 12:48 PM)menator01 Wrote: [ -> ]Without code it will be hard for anyone to help. You could try setColumnStretch()

I know for people to best help me I need to share code. But, I just don't feel like digging through and extracting the relevant sections to provide a MRE, especially when my app does what I want now. Like I said, this question is purely academic. I was hoping to solve it via StyleSheets, and in the process learn more about them. I thought it through prior to posting, and one really doesn't need code to fix the issue if it can be done via StyleSheets. StyleSheet syntax is straight forward. I shared what I've tried with them.

So, that's that.