Difficulty displaying frame around QTreeView

John Sturtz john at sturtz.org
Sat Sep 20 02:15:49 BST 2025


Hello again good PyQt folks.

I'm having a deal of trouble consistently displaying the frame that (I 
think) should appear around a QTreeView, which is embedded in a QDialog. 
  I specify the frame as follows:

         self.treeView.setFrameStyle(
             QtWidgets.QFrame.Shape.StyledPanel|
             QtWidgets.QFrame.Shadow.Raised
         )

Sometimes the frame doesn't display at all.  Sometimes parts of it will 
display (for example, three sides but not the fourth).

Attached is a sample script.  It does two different things (controlled 
by setting the boolean variable on line #14).

(1)
In one case, it creates a QTreeView, places it inside a QHBoxLayout, and 
puts the layout into the main layout for the QDialog.  On my computer, 
what I get in this case is frame on both sides and the bottom of the 
tree view, but not the top.

(2)
In the other case, the script creates the QTreeView, puts the tree view 
into a QHBoxLayout, then puts that layout into a QFrame and adds the 
frame to the dialog's main layout.  In that case, I get no frame around 
the tree view at all.

(Toggle between case 1 and case 2 by setting the boolean on line #14 to 
False or True, respectively).

Am I doing something wrong here?

BTW, this is Windows 11, and I have the System>Display Scale setting to 
125%.  It this possibly the cause of the problem?

Thanks again!

/John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20250920/d5dbdee2/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 3978 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20250920/d5dbdee2/attachment.py>


More information about the PyQt mailing list