QDarkStyleSheet icon indicating copy to clipboard operation
QDarkStyleSheet copied to clipboard

QComboBox renders icons on text-only items

Open nvzoll opened this issue 2 years ago • 4 comments

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

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

nvzoll avatar Feb 20 '22 11:02 nvzoll

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

ben-n93 avatar Feb 21 '22 02:02 ben-n93

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

glevner avatar May 30 '22 14:05 glevner

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)

aPeter1 avatar Aug 18 '22 02:08 aPeter1

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

fthmko avatar Aug 02 '23 08:08 fthmko