QTabWidget rendering issue?
Matic Kukovec
kukovecmatic at hotmail.com
Sun Apr 28 17:52:46 BST 2024
Thank you Maurizio,
I will try to create a minimal reproducible example.
In the mean while I found a workaround and a few more details:
This seems to happen when tabs for a QTabWidget are added without the QTabWidget
being actually shown yet in the main widget. The workaround I stumbled across is
on every 'currentChanged' check if the QTabWidget is not yet shown ('isVisible == False') and
then force a 'show()' on it and it's 'QTabWidget.tabBar()', that fixes it.
Regards,
Matic
________________________________
From: Maurizio Berti <maurizio.berti at gmail.com>
Sent: Sunday, April 28, 2024 5:24 AM
To: Matic Kukovec <kukovecmatic at hotmail.com>
Cc: PyQt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
Subject: Re: QTabWidget rendering issue?
This doesn't seem to be a PyQt related issue.
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.
Note that, if you're using QSS, you should always::
- ensure that you're using proper selectors, especially if the QSS is set on parents or the whole QApplication;
- remember that styling complex widgets requires setting *all* their properties as soon as even one is set; using generic properties (such as setStyleSheet('background: gray;')) at *any* level above any possibly affected widget may result in unexpected behavior;
- 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;
Cheers,
MaurizioB
Il giorno sab 27 apr 2024 alle ore 19:36 Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>> ha scritto:
I apologize, the screenshot for the overriden sizeHint method:
def sizeHint(self):
return super().sizeHint()*2
looks actually like this:
[cid:ii_18f22af1196cb971f164]
________________________________
From: Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>>
Sent: Saturday, April 27, 2024 7:23 PM
To: PyQt at riverbankcomputing.com<mailto:PyQt at riverbankcomputing.com> <pyqt at riverbankcomputing.com<mailto:pyqt at riverbankcomputing.com>>
Subject: Re: QTabWidget rendering issue?
Also note that any 'repaint', 'polish' and 'unpolish' methods on the QTabBar have no effect in the tab-bar in this state,
only clicking on another tab renders it correctly.
________________________________
From: Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>>
Sent: Saturday, April 27, 2024 7:09 PM
To: PyQt at riverbankcomputing.com<mailto:PyQt at riverbankcomputing.com> <pyqt at riverbankcomputing.com<mailto:pyqt at riverbankcomputing.com>>
Subject: Re: QTabWidget rendering issue?
I tried overriding the 'sizeHint' method of the QTabBar with this to see what would happen:
def sizeHint(self):
return super().sizeHint()*2
but that only changes the initial tabs to this:
[cid:ii_18f22af1195cb971f163]
________________________________
From: Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>>
Sent: Saturday, April 27, 2024 6:50 PM
To: Charles <peacech at gmail.com<mailto:peacech at gmail.com>>
Cc: PyQt at riverbankcomputing.com<mailto:PyQt at riverbankcomputing.com> <pyqt at riverbankcomputing.com<mailto:pyqt at riverbankcomputing.com>>
Subject: Re: QTabWidget rendering issue?
Ok, thanks, will do some testing into that direction.
________________________________
From: Charles <peacech at gmail.com<mailto:peacech at gmail.com>>
Sent: Saturday, April 27, 2024 6:34 PM
To: Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>>
Cc: PyQt at riverbankcomputing.com<mailto:PyQt at riverbankcomputing.com> <pyqt at riverbankcomputing.com<mailto:pyqt at riverbankcomputing.com>>
Subject: Re: QTabWidget rendering issue?
Maybe QTabWidget does not compute the sizeHint based on the custom font size?
On Sat, Apr 27, 2024 at 11:12 PM Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>> wrote:
This happens even without any styling changes, seen here:
[cid:ii_18f22af1195cb971f162]
Note that this is a plain vanilla QTabBar, no sub-classing.
Regards,
Matic
________________________________
From: Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>>
Sent: Saturday, April 27, 2024 12:59 PM
To: PyQt at riverbankcomputing.com<mailto:PyQt at riverbankcomputing.com> <pyqt at riverbankcomputing.com<mailto:pyqt at riverbankcomputing.com>>
Subject: QTabWidget rendering issue?
Hi guys,
Specs:
*
Windows 10 x64
*
Python 3.12
*
PyQt 6.6.1
I have a QTabWidget inside a layout and when initial layout is built not all of tabs are rendered.
The selected tab is rendered as the first tab, but when I select a different tab, all the tabs render correctly,
here is an example:
[cid:ii_18f22af1195cb971f161]
As you can see, when the initial layout is rendered the 'systick.c' tab is shown as the first, but in reality
the 'main.c' tab should be first, but it only appears after I click any non-current tab.
Any idea of where the problem is?
Regards,
Matic
--
È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240428/8031aa24/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 38763 bytes
Desc: image.png
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240428/8031aa24/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 34769 bytes
Desc: image.png
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240428/8031aa24/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 6562 bytes
Desc: image.png
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240428/8031aa24/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 16374 bytes
Desc: image.png
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240428/8031aa24/attachment-0007.png>
More information about the PyQt
mailing list