-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
QComboBox expands the last chosen item #200
Comments
@jkulskis could you try doing something like setting a styled delegate for the combo box? from PySide2 import QtCore, QtGui, QtWidgets
...
delegate = QStyledItemDelegate()
self.comboBox = QtWidgets.QComboBox(Dialog)
self.comboBox.setItemDelegate(delegate) |
@goanpeca This fixed the extra expansion, but now the combobox opens much higher than the dialog window instead of as a dropdown. |
Ok! We will see how we can fix that. Thanks for testing. |
Thank you for the quick help! |
Note this also happens on macOS -- same thing. Screenshot attached. It doesn't happen with PyQt5 5.12.x, but happens only starting with PyQt5 5.13.x. So the issue is not PySide-specific nor PyQt5 specific -- but rather depends on the underlying Qt version. (Works on 5.12, broken on 5.13). Screenshot |
This issue can be fixed by adding one line in style.qss and recompiling:
to QComboBox::item:checked so it reads
Do you want a PR for this? And if so, a PR with just this modified file, or do you want all recompiled rc files too? |
On Mojave with PyQt5 5.13.1 this still happens -- but with this fix it does not. Note that 14px for me looks better. But 12px is pretty good too. Consider adding this or something similar ... |
I also see thiis issue with the |
@goanpeca could you take a look at that? Tks |
Will do! QComboBoxes are a headache to style right :-| ! |
I see :( Thank you! |
I was also having this same problem with QComboBox. First I tried adding that height property like @asch99 recommended. I could not get it to work. Then I tried that original solution what @goanpeca suggested which is setting that styled delegate to ComboBox. That solution worked perfectly for me! My environment is as follows:
|
Yeah, I agree that my proposed solution does not seems to be the one-fix-for-all solution. What works reliably (so far) for me is to either modify the stylesheet of the combobox itself, or of the parent container. E.g. having an QApplication with a QTabWidget, containing (as a tab) a QWidget, containing a QComboBox then modifying the stylesheet of the QWidget or the QCombobox fixes the problem. However, modifying the stylesheet of the QApplication does not fix the problem. The applied modification is: The delegate solution also works, but then you loose part of the qdarkstyle formatting. |
@goanpeca some news about this one? Sorry for my lack of communication, now I want to run with these changes as I have a time. Thanks |
Not much :-| |
I changed this to next version, so we can release the 2.8 :) |
This worked for me on Linux Slackware 14.2, QDarkStyle 2.8 and Qt 5.14.1 |
qmodern does not have the failing QComboBox with PyQt5. Its own dark mode looks as good as this module. Perhaps we should use that instead? |
@jkulskis @tanimislam @mikeleppane Could you please check if the current solution in development works for everybody? |
Same thing in Ubuntu under QT until 6.6.0 |
Describe Your Environment
Please, report the output of the command (from v2.6+):
$ qdarkstyle --all
[Versions from your environment]
Language
Python
Description / Steps to Reproduce [if necessary]
Relevant UI setup code I used to add the combo box (generated by pyuic5) with a Dialog creation to provide a reproducible example:
When I open up the combobox, the item that was last chosen will increase in size as shown in the image below:

I tried to revert back to the default qt theme, and everything worked fine. I suspect it has something to do with Linux Mint or other aspects of my environment since I asked a question on StackOverflow, and a user commented that the code worked fine for them on linux.
The text was updated successfully, but these errors were encountered: