QDarkStyleSheet
QDarkStyleSheet copied to clipboard
QComboBox renders icons on text-only items
Environment
- QDarkStyle: v3.0.2-9-gcbc93c0
- OS: Linux Mint 20.1 Cinnamon
- Qt: 5.12.8
Language
C++
Description / Steps to Reproduce [if necessary]
Dropped down combobox displays icons for items with empty icons.
Actual Result
Expected Results / Proposed Result
Screenshot with app.setStyleSheet(...);
commented out.
Relevant Code
auto *cb = new QComboBox;
for (size_t i = 1; i <= 10; ++i) {
cb->addItem(QString::number(i));
}
Hi there, I have the same issue/question, however I am using Python/PyQt5.
We have the same issue with CentOS 7, Qt 5.12, QDarkStyle 3.0.2.
Hello! So you are aware, I am still having this issue on macOS Catalina, Python 3.8 (checked on 3.9 as well) using PyQt5 5.15.7 and QDarkStyle 3.1. Same results if I downgrade to an earlier version of PyQt5 (5.12.3)
Hello! So you are aware, I am still having this issue on macOS Catalina, Python 3.8 (checked on 3.9 as well) using PyQt5 5.15.7 and QDarkStyle 3.1. Same results if I downgrade to an earlier version of PyQt5 (5.12.3)
The generated qss content make this issue. I can't find out which line is wrong, but remove these sections will fix it.
QComboBox::indicator {
border: none;
border-radius: 0;
background-color: transparent;
selection-background-color: transparent;
color: transparent;
selection-color: transparent;
/* Needed to remove indicator - fix #132 */
}
QComboBox::indicator:alternate {
background: #FAFAFA;
}
This is my solution.
stylesheet = qdarkstyle.load_stylesheet(qt_api='pyside2')
stylesheet = re.sub(r'QComboBox::indicator([^}]|\n)+}', '', stylesheet, re.M)
app.setStyleSheet(stylesheet)
Set icon size of combox to 0 will looks better.
combo.setIconSize(QSize(0, 0))