Pyqt qss problem
- 在使用resource加载qss文件后,如果改动了qss文件发现没有效果,直接使用qss文件路径,产生效果。是否改了qss文件后要重新生成resource.py文件。
| Python | |
|---|---|
| Text Only | |
|---|---|
| Text Only | |
|---|---|
| Python | |
|---|---|
tabWidget->setStyleSheet("QTabBar { background-color: red; }"); tabWidget->setDocumentMode(true);
But it doesn’t look good.
Or via:
tabWidget->setAutoFillBackground(true); QPalette pal = tabWidget->palette(); pal.setColor(QPalette::Window, Qt::red); tabWidget->setPalette(pal);
Or just create QWidget with some background and insert QTabWidget on top of it.
- PyQt5 Tabwidget tab bar blank area background color
It depends on the
documentMode.
If it’s False (the default), you have to set the TabWidget background, and ensure that its autoFillBackground() is set to True; this is very important, as Qt automatically unselect it when setting a stylesheet.
Note that, in this case, the background will be “around” the whole tab widget too, if don’t want it, just disable the border.
| Python | |
|---|---|
If the document mode is on, instead, you can just set the background for the tab bar: