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

QComboBox renders icons on text-only items #308

Open
nvzoll opened this issue Feb 20, 2022 · 4 comments
Open

QComboBox renders icons on text-only items #308

nvzoll opened this issue Feb 20, 2022 · 4 comments

Comments

@nvzoll
Copy link

nvzoll commented Feb 20, 2022

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));
    }
@ben-n93
Copy link

ben-n93 commented Feb 21, 2022

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

@glevner
Copy link

glevner commented May 30, 2022

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

@aPeter1
Copy link

aPeter1 commented Aug 18, 2022

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
Copy link

fthmko commented Aug 2, 2023

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

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

No branches or pull requests

5 participants