[CLOSED] QComboBox doesn't disappear when app loses focus (Mac OS X)
-
[EDIT2]
it was a "bug":https://bugreports.qt-project.org/browse/QTBUG-35820[EDIT]
It behaves corretly in Windows environment,
but in Mac OS X environment QComboBox popup doesn't disappear when app loses focus.Any solution or workaround suggestion will be appreciated.
Thank you.
[/EDIT]
Hi,
After adding QComboBox to my application, I've noticed that the combobox continues to stay on top even when the application lost focus and some other application gained focus on top of my application.
(Qt Creator seems to work the same way)I want to use QComboBox::hidePopup() to hide the popup, but I'm not sure how to go about it.
Calling hidePopup() in leaveEvent(Event*) hides the popup as soon as it is opened,
QEvent::NonClientAreaMouseMove seems to work only for QWindow title bar
and I've been going through the QEvent list but nothing seems to help.
(googling yielded no helpful information either)Can somebody show me the right way to handle this, or at least point me in the right direction?
Thank you.
-
did you overwrite the popup view at all?
Because actually that should be the default behavior.Make sure your popup view has the window flag Qt::Popup set.
-
[quote author="raven-worx" date="1390290617"]did you overwrite the popup view at all?
Because actually that should be the default behavior.Make sure your popup view has the window flag Qt::Popup set.[/quote]
what I meant was, even though it's supposed to stay on top and everything, I want to hide it when I switch to other application.
I guess the real question here is "how to correctly detect that event of switching to another application"
-
yes, thats exactly what the window flag also takes care of.
Whenever the popup looses focus or the Escape key is pressed it gets closed. -
[quote author="raven-worx" date="1390291352"]yes, thats exactly what the window flag also takes care of.
Whenever the popup looses focus or the Escape key is pressed it gets closed.[/quote]sorry, I'm new to Qt and I'm not quite understanding your advice.
I've tried setWindowFlags(Qt::Popup) on:
my main window, which removed title bar and the ability to move window
the combobox, which made the combobox disappear
the combobox->view(), which made the contents of combobox disappear.could you give me little more detail please?
-
i meant you should set in only on the combobox->view().
But i think i still didn't get you right either.
Do you want the popup to be open all the time, even if the user switches focus inside your application? And only when your whole application window looses focus you want to hide the combobox popup?
-
[quote author="raven-worx" date="1390292502"]i meant you should set in only on the combobox->view().
But i think i still didn't get you right either.
Do you want the popup to be open all the time, even if the user switches focus inside your application? And only when your whole application window looses focus you want to hide the combobox popup?[/quote]
I don't want to change the default behaviour inside the application (the popup should disappear when I click elsewhere inside the application), but second part is as you say.
-
i just checked the default behavior is:
a Qt::Popup window flag on the combobox popup. This widget is of type QComboBoxPrivateContainer (not part of the public API, so nothing you have to worry about) and has set the popup window flag by default.
This ensures that the popup gets closed on every focus change outside the popup (including the the application window)If this isn't the case it is prevented somewhere in the code you wrote.
-
Ok, thank you for your time.
I'm actually looking at somebody else's code, so I'll look into other parts of the program and see if I've missed something from his code.
-
Oh, there's something I forgot to mention.
I am developing and testing in Mac OS X environment.
(probably the reason for some of the miscommunication)I tested my application in Windows 7.0 environment as an afterthought, and it works fine.
But the same code still seems to work differently in Mac OS X.In Windows environment QComboBox popup disappears when the app loses focus (as it should), but in Mac OS X environment QComboBox popup does not disappear and continues to stay on top of everything else.
-
I've changed the title and the content to reflect updated status of my problem.
-
the bug will be fixed in 5.2.1
-
@thebeast44 said in [CLOSED] QComboBox doesn't disappear when app loses focus (Mac OS X):
the bug will be fixed in 5.2.1
i have the same issue (linux debian on beaglebone black with touchscreen)