How to have a different initial background color for popups shown with <select>?
-
I have an application using a QWebEngineView . In this QWebEngineView, I use a <select> to display a popup menu. The application itself and the popup are customized to have a black background color. However when the popup is shown, a white background is initially used: it seems to flash shortly white.
I tried to set an initial black background color to the popup with no success. I made a subclass of QWebEngineView to catch the childEvent events. I was able to get the QEvent::ChildAdded and QEvent::ChildPolished events. I can get the QWidget pointer, however have not been able to change the background color.
void AAAAAAWebEngineView::childEvent(QChildEvent *e) { QWebEngineView::childEvent(e); if (e->child()->isWidgetType()) { if (e->type() == QEvent::ChildAdded || e->type() == QEvent::ChildPolished) { QObject *child = e->child(); QWidget *widget = dynamic_cast<QWidget *>(child); if(widget != NULL) { widget->setStyleSheet("background-color: red;"); } } } }
One of the QWidget I get is a RenderWidgetHostViewQtDelegateWidget with the property m_isPopup set to true, so I guess this is the right QWidget. Trying to change the background color using a style sheet has no effect.
Does anyone know how to set a different initial background color for popups shown with <select>?