<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you Maurizio,</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I will try to create a minimal reproducible example.</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
In the mean while I found a workaround and a few more details:</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This seems to happen when tabs for a QTabWidget are added without the QTabWidget</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
being actually shown yet in the main widget. The workaround I stumbled across is</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
on every 'currentChanged' check if the QTabWidget is not yet shown ('isVisible == False') and</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
then force a 'show()' on it and it's 'QTabWidget.tabBar()', that fixes it.</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regards,</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Matic</div>
<div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Maurizio Berti <maurizio.berti@gmail.com><br>
<b>Sent:</b> Sunday, April 28, 2024 5:24 AM<br>
<b>To:</b> Matic Kukovec <kukovecmatic@hotmail.com><br>
<b>Cc:</b> PyQt@riverbankcomputing.com <pyqt@riverbankcomputing.com><br>
<b>Subject:</b> Re: QTabWidget rendering issue?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>This doesn't seem to be a PyQt related issue.</div>
<div><br>
</div>
<div>I suggest you to provide a proper minimal reproducible code, either here or at least on a Qt forum or StackOverflow post, and eventually share the link here.</div>
<div><br>
</div>
<div>Note that, if you're using QSS, you should always::</div>
<div>- ensure that you're using proper selectors, especially if the QSS is set on parents or the whole QApplication;</div>
<div>- remember that styling complex widgets requires setting <b>*all*</b> their properties as soon as even one is set; using generic properties (such as
<span style="font-family:monospace">setStyleSheet('background: gray;')</span>) at
<b>*any*</b> level above any possibly affected widget may result in unexpected behavior;</div>
<div>- consider that QSS are always inherited by child widgets, so verify that you're not setting any generic/arbitrary QSS with code or by using a Designer UI;</div>
<div><br>
</div>
<div>Cheers,</div>
<div>MaurizioB<br>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">Il giorno sab 27 apr 2024 alle ore 19:36 Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com">kukovecmatic@hotmail.com</a>> ha scritto:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div class="x_msg-1237662211449779369">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I apologize, the screenshot for the overriden sizeHint method:</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="margin-left:40px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
def sizeHint(self):<br>
return super().sizeHint()*2</div>
<div style="margin-left:0px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="margin-left:0px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
looks actually like this:</div>
<div style="margin-left:0px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<img size="16374" style="max-width:1062px" data-outlook-trace="F:1|T:1" src="cid:ii_18f22af1196cb971f164"></div>
<div id="x_m_-1237662211449779369appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-1237662211449779369divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com" target="_blank">kukovecmatic@hotmail.com</a>><br>
<b>Sent:</b> Saturday, April 27, 2024 7:23 PM<br>
<b>To:</b> <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a> <<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>><br>
<b>Subject:</b> Re: QTabWidget rendering issue?</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Also note that any 'repaint', 'polish' and 'unpolish' methods on the QTabBar have no effect in the tab-bar in this state,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
only clicking on another tab renders it correctly.</div>
<div id="x_m_-1237662211449779369x_appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-1237662211449779369x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com" target="_blank">kukovecmatic@hotmail.com</a>><br>
<b>Sent:</b> Saturday, April 27, 2024 7:09 PM<br>
<b>To:</b> <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a> <<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>><br>
<b>Subject:</b> Re: QTabWidget rendering issue?</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I tried overriding the 'sizeHint' method of the QTabBar with this to see what would happen:</div>
<div style="margin-left:40px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="margin-left:40px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
def sizeHint(self):<br>
return super().sizeHint()*2</div>
<div style="margin-left:0px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="margin-left:0px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
but that only changes the initial tabs to this:</div>
<div style="margin-left:0px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<img size="6562" style="max-width:1062px" data-outlook-trace="F:1|T:1" src="cid:ii_18f22af1195cb971f163"></div>
<div id="x_m_-1237662211449779369x_x_appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-1237662211449779369x_x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com" target="_blank">kukovecmatic@hotmail.com</a>><br>
<b>Sent:</b> Saturday, April 27, 2024 6:50 PM<br>
<b>To:</b> Charles <<a href="mailto:peacech@gmail.com" target="_blank">peacech@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a> <<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>><br>
<b>Subject:</b> Re: QTabWidget rendering issue?</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Ok, thanks, will do some testing into that direction.</div>
<div id="x_m_-1237662211449779369x_x_x_appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-1237662211449779369x_x_x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Charles <<a href="mailto:peacech@gmail.com" target="_blank">peacech@gmail.com</a>><br>
<b>Sent:</b> Saturday, April 27, 2024 6:34 PM<br>
<b>To:</b> Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com" target="_blank">kukovecmatic@hotmail.com</a>><br>
<b>Cc:</b> <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a> <<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>><br>
<b>Subject:</b> Re: QTabWidget rendering issue?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div style="font-family:arial,helvetica,sans-serif; font-size:small">Maybe QTabWidget does not compute the sizeHint based on the custom font size?<br>
</div>
</div>
<br>
<div>
<div dir="ltr">On Sat, Apr 27, 2024 at 11:12 PM Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com" target="_blank">kukovecmatic@hotmail.com</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
This happens even without any styling changes, seen here:</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<img size="34769" style="max-width:1062px" data-outlook-trace="F:1|T:1" src="cid:ii_18f22af1195cb971f162"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Note that this is a plain vanilla QTabBar, no sub-classing.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Matic</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="x_m_-1237662211449779369x_x_x_x_m_-4961569117981197639appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-1237662211449779369x_x_x_x_m_-4961569117981197639divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Matic Kukovec <<a href="mailto:kukovecmatic@hotmail.com" target="_blank">kukovecmatic@hotmail.com</a>><br>
<b>Sent:</b> Saturday, April 27, 2024 12:59 PM<br>
<b>To:</b> <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a> <<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>><br>
<b>Subject:</b> QTabWidget rendering issue?</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi guys,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Specs:</div>
<ul>
<li style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Windows 10 x64</div>
</li><li style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Python 3.12</div>
</li><li style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
PyQt 6.6.1</div>
</li></ul>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I have a QTabWidget inside a layout and when initial layout is built not all of tabs are rendered.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
The selected tab is rendered as the first tab, but when I select a different tab, all the tabs render correctly,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
here is an example:</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<img size="38763" style="max-width:1072px" data-outlook-trace="F:1|T:1" src="cid:ii_18f22af1195cb971f161"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
As you can see, when the initial layout is rendered the 'systick.c' tab is shown as the first, but in reality</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
the 'main.c' tab should be first, but it only appears after I click any non-current tab.</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Any idea of where the problem is?</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Regards,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Matic</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<br>
<span class="x_gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="x_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>
</div>
</body>
</html>