ColinDuquesnoy / QDarkStyleSheet

A dark style sheet for QtWidgets application
Other
2.76k stars 725 forks source link

QComboBox renders icons on text-only items #308

Open nvzoll opened 2 years ago

nvzoll commented 2 years ago

Environment

Language

C++

Description / Steps to Reproduce [if necessary]

Dropped down combobox displays icons for items with empty icons.

Actual Result

actual

Expected Results / Proposed Result

expected

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));
    }
ben-n93 commented 2 years ago

Hi there, I have the same issue/question, however I am using Python/PyQt5.

glevner commented 2 years ago

We have the same issue with CentOS 7, Qt 5.12, QDarkStyle 3.0.2.

aPeter1 commented 1 year ago

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)

fthmko commented 11 months ago

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))