Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to change the color of the text of QTabBar with setTabTextColor #212

Closed
jnsebgosselin opened this issue Nov 28, 2019 · 7 comments
Assignees
Milestone

Comments

@jnsebgosselin
Copy link

[Versions from your environment]

  • QDarkStyle: commit 716979b on develop
  • Python 3.7.3 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10
  • Python: 3.7

Setting the color of the text of individual tab in QTabBar with QTabBar.setTabTextColor is not working when using qdarkstyle

Below I present an example that demonstrate the issue.

image

Relevant Code [if necessary]

from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication, QTabWidget, QWidget
import sys
import qdarkstyle

app = QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())

tabwidget = QTabWidget()
colors = ('red', 'green', 'black', 'blue')
for i, color in enumerate(colors):
    tabwidget.addTab(QWidget(), 'Tab #{}'.format(i + 1))
    tabwidget.tabBar().setTabTextColor(i, QColor(color))

tabwidget.show()
tabwidget.setMinimumWidth(300)
sys.exit(app.exec_())
@dpizetta
Copy link
Collaborator

Not sure how to provide this change. The tab widget does not accept QLabel, and HTML text is rendered colored as desired, but it stills with the HTML code be shown.

@goanpeca
Copy link
Collaborator

@dpizetta if we do not provide a color style for the whole tab widget text color this wotks, but as soon as we provide that color, then set tabcolor stops working with qdarkstyle.

One option would be to not enforce that color?

@dpizetta
Copy link
Collaborator

@goanpeca we can try that :) Tks

@dpizetta
Copy link
Collaborator

@dpizetta if we do not provide a color style for the whole tab widget text color this works, but as soon as we provide that color, then set tabcolor stops working with qdarkstyle.

One option would be to not enforce that color?

@goanpeca have you tried this? I do, but it stills having the problem. It would be inheriting. It does not work. I suggest @jnsebgosselin use icon if possible. If anyone has another idea, please let me know.

Screenshot from 2020-01-16 15-44-43

@goanpeca
Copy link
Collaborator

I remeber trying something along the lines I said and it worked but I would need to check again.

@dpizetta dpizetta added this to the 2.9 milestone Jan 20, 2020
@dpizetta dpizetta removed this from the 2.9 milestone Mar 29, 2021
@dpizetta
Copy link
Collaborator

dpizetta commented Apr 1, 2021

@jnsebgosselin now it should be working :)

@dpizetta dpizetta added this to the 3.0 milestone Apr 1, 2021
@jnsebgosselin
Copy link
Author

This is excellent, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants