Styling of QLineEdit/QListView child of QCombobox on hover
-
So I wanted a QComboBox with checkboxes and after seeing lots of problems with the normal implementation I found this when I searched
https://stackoverflow.com/questions/8422760/combobox-of-checkboxesEspecially this code:
https://gist.github.com/mistic100/c3b7f3eabc65309687153fe3e0a9a720However, this has some limitations I don't know if it's possible to work around with styling which also is an important part of my project making it look just like the other comboboxes.
The problem is my comboboxes uses padding and a background color on hover.
QLineEdit:hover { background-color: red; }
This would only work when my mouse is over the lineEdit and not the padded area leaving the QLineEdit with a white background when it's not over the exact QLineEdit
So coming from CSS (which is absolutely superior to Qts styling btw) I tried this:
QComboBox:hover QLineEdit { background-color: red; }
But no change.
Is there even a solution?
Another problem would be that the selection-background-color of "QComboBox QAbstractView" doesn't work with this solution above and I'm not using any custom styled delegates yet.
Hope you understand where I'm getting at.
-
Still looking for help with this if its even possible this is how it looks on hover right now.
Even thinking about subclassing QLineEdit to force hover-effect but not sure how.
-
@mikael-larsson
Hi
You could try an event filter on the Combobox and call the code for hover effect but
if your effect is purely stylesheet based then i think you then must send it fake hover event to trigger it or something like that.You might also be able to subclass the combo and rig the paintEvent with
if (someflag)
option.state |= QStyle::State_MouseOver;to trigger hover on command from the event filter/ or combo hover or how you plan to trigger it.