Pyside2 - While QCombobox is opened, click on gui sends gui to back and focus on other window, in windows 10
-
If I run the sample code below on windows 10,Ubuntu, and Centos6 in a python3.7/ Pyside2(5.13.1) env (built with anaconda), I get different focus behavior with the QCombobox. It seems to work correctly in Linux but in windows 10 if I click a Qcombobox and display the items, then click on the gui out side of the combobox items, the focus is lost and the gui is sent to the back of any other windows open.
Is there anything on the windows side that might be triggering this? Ideally I dont want to brute force the windowsFlag always on top hint, just for windows 10... Any help greatly appreciated
from PySide2 import QtWidgets class MyWindow(QtWidgets.QMainWindow): def __init__(self): super(MyWindow, self).__init__() self.edit = QtWidgets.QComboBox() self.edit.addItems(['item1', 'item2', 'item3']) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.edit) w = QtWidgets.QWidget() w.setLayout(layout) self.setCentralWidget(w) if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) window = MyWindow() window.show() sys.exit(app.exec_())
-
@Denni-0
Thanks for taking a look at the sample.
Actually the gui (QMainWindow) is whats being clicked once the combo box is opened, so I would think the QMainWindow should still be on top of any other windows below it. So clicking any where on the QMainWindow other than the combobox sends it back. -
@alom I think the behaviour you're describing on Windows and Linux are simply OS preferences. On Windows the Window you're clicking on is raised even if the current window has an "open" combo box. On Linux only the combo box is closed on first click outside of the window. I would not to try to change this as users are used to the behaviour of their systems.
-
OK good to know you are not experiencing it, yep the behavior is still happening running from a bat file.
Maybe something is on my box...I cant think of anything that might be triggering this. I don't have a clean windows install to start debugging. The only thing I can see might be an issue is my wacom tablet and turning off windows ink features?
-
thanks, so I was able to get another windows 10 box and was not able to reproduce this behavior either with the same IDE and env.
Unfortunately there is something on my workstation causing this...I did find another consistent behavior on my workstation with this issue. After the first click once the gui goes behind another window, if you try again, the windows stays on top as expected. So it's only on the first click out side a opened combo box, very strange.