QTabWidget selected tab text blank

Heads up! You've already completed this tutorial.

Mr_S_J_Childerley | 2021-01-06 18:58:45 UTC | #1

I've used QTabWidget successfully on windows 10 in the past without an issue. However using on a mac running macOS 11.0.1 I am seeing the text of the selected tab, when it has focus, being blanked out. QTabWidget_Selected|412x78

The tab text (gets unblanked) only appears when the tab looses focus: QTabWidget_de_Selected|414x70

I suspect there is perhaps a style setting to fix this. However I would have expected the default to do sensible things.

Any ideas?

Version data as follows: PYQT_VERSION = 329986 PYQT_VERSION_STR = 5.9.2 QOpenGLVersionProfile = QOperatingSystemVersion = QT_VERSION = 329990 QT_VERSION_STR = 5.9.6


martin | 2021-01-06 20:17:47 UTC | #2

Hey there! I've made a little test application and ran it on macOS 10.15 (Catalina) and the tabs appear to be working correctly there.

python
from PyQt5.QtWidgets import QTabWidget, QApplication, QWidget

app = QApplication([])
tab = QTabWidget()

w = QWidget()
tab.addTab(w, 'Hello')

w = QWidget()
tab.addTab(w, 'Test')

w = QWidget()
tab.addTab(w, 'Another')

tab.show()

app.exec_()

...which shows the following (tested dark mode also) --

Screenshot 2021-01-06 at 21.12.06|624x468

Can you try this test to rule out any issues specific to your application? If this example doesn't work I can try upgrading one of my machines to 11.0 myself. Or perhaps you can try PyQt5 5.15.2 (latest) ?


Mr_S_J_Childerley | 2021-01-06 21:01:50 UTC | #3

Thanks Martin, with your example I got the same. Martins_example|502x344 I'll try/attempt the upgrade to PyQt5 5.15.2

Appreciated.


Mr_S_J_Childerley | 2021-01-06 21:28:25 UTC | #4

Slightly against my better judgement I pip installed PyQt5 5.15.2 into the failing conda environment. Martin_example_5.15.2|610x458 Which fixed the issue. Not intending to make an installable version for a while, when I might regret this!


martin | 2021-01-07 08:12:06 UTC | #5

Ah great, glad that's fixed it -- I wasn't looking forward to upgrading my mac! :slight_smile:

I've leave a note that you've done this in your requirements.txt / docs or similar, so you don't forget when you come to build. Easy to lose hours on forgotten quick fixes!


The complete guide to packaging Python GUI applications with PyInstaller.
[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

QTabWidget selected tab text blank was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.