Solved Customizing QComboBox
-
@raven-worx
Thanks, yes this helps, but side effect is that expand/collapse button stops working. i'll go to browse the qt's sources to find out the reason. -
@Ivan-Netskin
Hi
bool QComboBoxPrivateContainer::eventFilter
is stealing the mouseReleased from you.
( i think :) -
@mrjj
yep , probably these lines :case QEvent::MouseButtonRelease: { bool ignoreEvent = maybeIgnoreMouseButtonRelease && popupTimer.elapsed() < QApplication::doubleClickInterval(); QMouseEvent *m = static_cast<QMouseEvent *>(e); if (isVisible() && view->rect().contains(m->pos()) && view->currentIndex().isValid() && !blockMouseReleaseTimer.isActive() && !ignoreEvent && (view->currentIndex().flags() & Qt::ItemIsEnabled) && (view->currentIndex().flags() & Qt::ItemIsSelectable)) { combo->hidePopup(); emit itemSelected(view->currentIndex()); return true; } break; }
-
yep i think so.
But it seems you can get MouseDown so maybe u can maybe cheat and hax it that way
and make it close. -
customizing qcombobox is a bit pain. Changing little option may result in
an unexpected behaviour of the enitre combobox. Is there a way to get expandable list, even if the list inside layout? -
@Ivan-Netskin
Well you are fiddling with the core logic. That often leads to side effects.Qt is using private classes to increase compatibility but it also often kills
true reuse as only the virtual function the developers could imagine are
there to override. But it's worth it :)Also note, you can chain event filters so you might be able that way.
However, if you only need combobox then QListWidget and QPushbutton could
be use to make fake one. If you need the edit part it becomes more complicated.
set Min/max and fixed size are still allowed in layouts. -
thanks for reply, the problem is that if i change the widget size,which lies in layout - it will result in growing size of the whole application. This is undesirable behaviour in my case. Also just creating a listview widget without parent and moving it under the QCombobox looks like unclean solution a bit.
-
@Ivan-Netskin
ok. it must be floating then :)
Before giving up on your custom combobox I would have a look at the eventfilter docs.
You might be able to put yourself in front and control it that way. -
found something appropriate - http://libqxt.bitbucket.org/doc/tip/qxtcheckcombobox.html
-
@Ivan-Netskin
But will it stay open ? -
From discription it's allowing to select multiple items - that's good enough