PyQt5 & QDialog Mouse Focus
-
I do not know if this is specific to PyQt5 or not, but posting here on suspicion it is.
I seem to be hitting a mouse focus problem when displaying a modal QDialog on OS X when using PyQt5 (Python 3.5) w/Qt5.5.
From the main app window I am showing a modal dialog with dlg.exec(). The dialog contains a number of QLineEdits. I have set the focus to the first QLineEdit prior to calling dlg.exec(), and that works fine. But the application, or at least the modal dialog, seems to lose mouse focus. After the QDialog appears, hovering over any of the other (not the first) QLineEdits, does not change the cursor to the insertion cursor, and I have to click twice to give the QLineEdit input keyboard focus. The first click seems to give the dialog the mouse focus, and the cursor changes, then the second click will change input focus.
I have also noticed the following:
- If upon the QDialog appearing, I first click the window title bar of either the QDialog or the MainWindow (behind it), the cursor changes appropriately when hovering, and only a single click is required to change the input focus.
- The dialog has a QButtonBox, and the CANCEL button (which is not the default button) behaves the same way, i.e., it takes two clicks to change focus.
- After the first "pair" of clicks, I can click anywhere and the focus changes as I would expect. Another reason why I suspect it has to do with the entire App focus.
- At all times the operating system is displaying the application as the app with focus.
- The tab order has been set on the QLineEdits, and Tabs move focus just fine.
Any help, suggestions, solutions greatly appreciated!