qt - Style QComboBox's sub-control down-arrow when mouse is hovering over the QComboBox via QSS -
i know how style qcombobox
when mouse hovering doing:
pcombobox->setstylesheet(pcombobox->stylesheet()+qstring(" qcombobox:hover{css style here}"))
and know style qcombobox
's sub-control down-arrow's style via:
pcombobox->setstylesheet(pcombobox->stylesheet()+qstring(" qcombobox::down-arrow{css style here}"))
but don't know how style qcombobox
's sub-control down-arrow
when mouse hovering on qcombobox
via qss
. have idea?
i don't know qss
powerful enough this(i think no), eventfilter
can easy:
bool mainwindow::eventfilter(qobject *obj, qevent *event) { if (obj == ui->combobox && event->type() == qevent::enter) { //user enters combobox, apply stylesheet ui->combobox->setstylesheet("qcombobox::down-arrow{background-color: red}"); } else if(event->type() == qevent::leave)//user leaves combobox, set default settings ui->combobox->setstylesheet(""); return qobject::eventfilter(obj, event); }
to use eventfilter
should also:
protected: bool eventfilter(qobject *obj, qevent *event);//in header
and
qapp->installeventfilter(this);//in constructor
Comments
Post a Comment