Hi,
I have built a custom combo box, its basically a Widget with 2 buttons. Clicking on any of them displays another widget below them, showing the combo.
This combo displays the items with a Tree View, This is used to display an AddressBar, where the main/root items are the names of the contacts and the subitems (childs) are the several emails of each person.
The thing is that in order to simulate the QComboBox behaviour, the combo must disappear when the user clicks outside or when clicking on the buttons again.
For the combo i have used a Widget as a wrapper for the TreeView, applying the Qt::Popup flag. That didnt help. Popup widgets by default get hidden when clicking outside, but in the case i click on the button, the combo was hidden and as a result of clicking outside of the view, then the click was detected on the button and the view was shown again, since it was not visible. I couldnt hide the view when clicking back on the button.
What i found out is that: when the QWidget is visible, it get the mouse press event. Checks if the event position is inside it, and if so, hides it. When the widget is hidden, then the click event is detected on the button.
So i overrided the implementation of MousePressEvent in the QWidget that wrapps the QTreeView to play a little, copying exactly what QWidget does, and i found that if i DONT hide the QWidget on the mousePressEvent, then the click is NOT detected on the button.
Is it possible that the MousePressEvent is not propagating the event when the QWidget is visible? The QWidget has no parent at all, but when hidden by the mouse click, the event is informed to the button.
Any ideas?
Thanks
Bookmarks