Python Forum
[PyQt] QTreeView, StyleSheet resizes last column
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] QTreeView, StyleSheet resizes last column
#1
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?
Reply


Messages In This Thread
QTreeView, StyleSheet resizes last column - by malonn - Sep-15-2023, 09:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] Changing a column header in QTreeView DrakeSoft 4 3,780 Jun-25-2022, 09:11 AM
Last Post: DrakeSoft
  [PyQt] QTableWidget stylesheet error mart79 3 6,564 Feb-26-2020, 04:54 PM
Last Post: Denni
  [PyQt] How to reference QTreeView QHeaderView setResizeMode Denni 1 3,820 Jun-11-2019, 10:20 PM
Last Post: Alfalfa
  Cannot Import stylesheet BG? mekha 1 2,318 Aug-08-2018, 04:49 AM
Last Post: mekha
  [PyQt] QTreeView branches and their clickable area not coinciding abstracted 0 3,814 Mar-17-2017, 02:28 AM
Last Post: abstracted

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020