Unsolved drop down > ?
-
how can i auto drop down comboBox when mouse hover into it ?
-
Hi
well you can subclass it and overwrite the enter event and then call
https://doc.qt.io/qt-5/qcombobox.html#showPopup
or use an event filer to look for enter and do the same.sorry its
void QWidget::enterEvent(QEvent *event)
void QWidget::leaveEvent(QEvent *event) -
Hi,
You can use showPopup to force the drop down to show.
-
@mrjj just mouse hover not enterEvent
-
You can use the QMouseHoverEvent.
See the class details on how to enable it.
-
@Duy-Khang
Yes You are right. enterEvent is a bit too aggressive :)
Update:
HoverEvent is less fast. but not as much as i expected.class combo : public QComboBox { public: explicit combo(QWidget *parent ) : QComboBox(parent) { setAttribute(Qt::WA_Hover); } protected: virtual bool event(QEvent *event) override { switch (event->type()) { case QEvent::HoverEnter: if ( ! view()->isVisible() ) { showPopup(); } return true; break; case QEvent::HoverLeave: return true; break; case QEvent::HoverMove: return true; break; default: break; } return QComboBox::event(event); } };