<div dir="ltr"><div><div>First of all, please be aware that this is almost certainly <b>not</b> a PyQt issue.</div><div><br></div><div>After that, if you're not certain if the display scaling may be related, the simplest solution is to simply change your display settings and see what happens.</div><div><br></div><div>Then, some Qt widget types may behave differently depending on their relationship within the window management environment: the same QWidget can have different appearance and metrics (including margins, borders, etc.) depending on many aspects: QWidget subclasses (standard Qt types or custom subclasses) may work differently if they're top level windows or not, which also is quite relevant for dialogs (which can be treated differently depending on the OS, including different versions of the same platform).</div><div><br></div>Some further suggestions:<br>- make a practical, immediate comparison; don't ask people to manually test differences (which may be difficult to compare across modifications) or modify your code in ways that would potentially invalidate your case: create a program that shows *two* windows with the different container_frame value (possibly with a related window title to simplify recognition) so that everybody can easily see the differences at a glance;<br><div>- check if adding contents to a different *and/or* further container makes any difference (eg: use QWidget instead of QDialog, then also try to add the different "windows" to a main top level window); it's quite normal for a container widget to display itself differently depending on the window management relation: a "frame" may need a visual hint when added to a further layout for which it may be part of a more relevant "widget hierarchy", while that hint may not be that relevant if it's a top level window itself;</div><div>- remember that Qt scroll areas all inherit from QAbstractScrollArea, which in turn inherits from QFrame, making the above statement even more relevant; some styles draw contents quite differently depending on their "level" within the top level window (the base QWidget itself behaves differently in some situations, depending on its top level state);</div><div>- Qt widget styling is quite complex and not always perfect; I've seen some cases of widgets behaving/displaying differently depending on when/how they're created or added to a parent, because some widgets (especially complex ones such as scroll areas) are in part definitively "initialized" at some point and not properly updated afterwards, even if the parent (or the style) has changed;<br></div>- also remember that, while the "fusion" style is intended to be as consistent as possible across different systems, every platform, OS version, system (hw+sw) and user configuration has its own quirks; specifically, some "metrics" and related appearances (frames, boxes, paddings, margins and related appearances, even including border sizes and their display) will always potentially be shown somehow differently, even on theoretically "similar" systems;</div><div>- finally, while relatively rare, even the above compliant "fusion" style has received some updates, even indirectly (possibly causing some regressions due to the introduction of changes that may affect it; consider the case of the "modern" window style introduced in Qt 6.7);<br></div><div><br></div><div>Best regards,</div><div>MaurizioB<br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Il giorno sab 20 set 2025 alle ore 03:15 John Sturtz <<a href="mailto:john@sturtz.org">john@sturtz.org</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg-4369500857033672080">



<div>Hello again good PyQt folks.<div><br></div><div>I'm having a deal of trouble consistently displaying the frame that (I think) should appear around a <font face="Consolas">QTreeView</font>, which is embedded in a <font style="font-size:16px" size="3" face="Consolas">QDialog</font>.  I specify the frame as follows:</div><div><br></div><div><font style="font-size:16px" size="3" face="Consolas">        self.treeView.setFrameStyle(
</font></div><div><font style="font-size:16px" size="3" face="Consolas">            QtWidgets.QFrame.Shape.StyledPanel|
</font></div><div><font style="font-size:16px" size="3" face="Consolas">            QtWidgets.QFrame.Shadow.Raised
</font></div><div><font style="font-size:16px" size="3" face="Consolas">        )
</font></div><div style="font-size:16px"><br></div><div>Sometimes the frame doesn't display at all.  Sometimes parts of it will display (for example, three sides but not the fourth).</div><div><br></div><div>Attached is a sample script.  It does two different things (controlled by setting the boolean variable on line #14).</div><div><br></div><div>(1)</div><div>In one case, it creates a <font style="font-size:16px" size="3" face="Consolas">QTreeView</font>, places it inside a <font style="font-size:16px" size="3" face="Consolas">QHBoxLayout</font>, and puts the layout into the main layout for the <font style="font-size:16px" size="3" face="Consolas">QDialog</font>.  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.</div><div><br></div><div>(2)</div><div>In the other case, the script creates the <font style="font-size:16px" size="3" face="Consolas">QTreeView</font>, puts the tree view into a <font style="font-size:16px" size="3" face="Consolas">QHBoxLayout</font>, then puts that layout into a <font style="font-size:16px" size="3" face="Consolas">QFrame</font> and adds the frame to the dialog's main layout.  In that case, I get no frame around the tree view at all.</div><div><br></div><div>(Toggle between case 1 and case 2 by setting the boolean on line #14 to <font style="font-size:16px" size="3" face="Consolas">False</font> or <font style="font-size:16px" size="3" face="Consolas">True</font>, respectively).</div><div><br></div><div>Am I doing something wrong here?</div><div><br></div><div>BTW, this is Windows 11, and I have the <font style="font-size:16px" size="3" face="Consolas">System>Display</font> Scale setting to 125%.  It this possibly the cause of the problem?</div><div><br></div><div>Thanks again!</div><div><br></div><div>/John</div></div></div></blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net" target="_blank">http://www.jidesk.net</a></div>