PyQt Window Focus

前端 未结 3 2018
孤独总比滥情好
孤独总比滥情好 2021-01-18 00:49

I am trying to give focus to a window if the user clicks on another window.

Right now i have two windows: Window A is behind, and Window B is in front. When Window B

3条回答
  •  猫巷女王i
    2021-01-18 01:14

    class window_b(QtGui.QDialog):
        def __init__(self,parent=None):
            super(window_b, self).__init__(parent)
            window_a.setEnabled(False)
            self.ui = Ui_Form_window_b()
            self.ui.setupUi(self)
            self.setWindowModality(QtCore.Qt.ApplicationModal)
            self.setFocusPolicy(QtCore.Qt.StrongFocus)
    
        def focusOutEvent(self,event):
            self.setFocus(True)
            self.activateWindow()
            self.raise_()
            self.show()
    
    

提交回复
热议问题