MouseButtonRelease does not work on Linux after populating the combo box
-
Hi,
I have an event Filter for a comboBox. The issue I'm having is when I use MouseButtonRelease and select the drop down arrow, it only catches the signal if there is no data in the combo box. This is true only on Linux/MAC. Once data is loaded the signal is not caught. On windows it works just fine.
If I use MouseButtonPress then it always works but the dropdown bounces back up after I release the mouse button to make a selection. This is why I prefer to use MouseButtonRelease unless there is a better alternative.
Any ideas?
//Assign event filter to the comboBox
ui->ipStringValueComboBox->installEventFilter(this);Further down:
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{if(event->type() == QEvent::MouseButtonRelease)
{
if(object == ui->ipStringValueComboBox)
IPComboBoxClicked();return true;
}
else
return false;}
void MainWindow::IPComboBoxClicked()
{
//do some stuff
ui->ipStringValueComboBox->showPopup();}
Thanks again.
-
What do you try to achieve? Why do you need an eventfilter at all?
You're filtering the event so it will not get delivered to where it should go so this might cause some strange behavior. -
@leinad said in MouseButtonRelease does not work on Linux after populating the combo box:
I need to know when the user clicks on the down arrow of the combo box.
Why
I see no signals to handle that so I use an event filter. What is a better way?
But then don't filter out the event and let it go to where it belongs.
-
If I understand what you mean, I simply modified the code like this:
bool MainWindow::eventFilter(QObject *object, QEvent *event)
{
Q_UNUSED(event);if(object == ui->ipStringValueComboBox) IPComboBoxClicked(); return true;
}
It compiles but the app does not come up.
-
@leinad said in MouseButtonRelease does not work on Linux after populating the combo box:
It compiles but the app does not come up.
I would not expect anything else - now every event which is sent to ipStringValueComboBox triggers IPComboBoxClicked() which then calls ui->ipStringValueComboBox->showPopup() ...
Why do you need this at all?
-
@leinad said in MouseButtonRelease does not work on Linux after populating the combo box:
Ok, so how do I implement when someone clicks on the arrow
Like you did in your first post, but don't discard the event: QObject::eventFilter()
But I still don't see a reason why you should call QComboBox::showPopup() by your own...