我在将焦点设置在主窗口的四个子窗口之一时遇到问题。我尝试将 setFocus 设置为四个之一,但主窗口仍然保持焦点。我有一个组合框,可让您选择四个窗口中的哪一个成为焦点。每个寡妇都在单独的监视器上。
from PyQt4 import QtGui, QtCore
import numpy as np
from ui_GuiMask import Ui_MainWindow
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent = None):
QtGui.QMainWindow.__init__(self, parent)
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
QtCore.QObject.connect(self.ui.cb_projectorSelector, QtCore.SIGNAL("currentIndexChanged(int)"), self.setProjectorFocus)
self.maskProjector_1 = MaskWindow(screen = 0)
self.maskProjector_1.show()
self.maskProjector_2 = MaskWindow(screen = 0)
self.maskProjector_2.show()
def setProjectorFocus(self):
whichProj = self.ui.cb_projectorSelector.currentIndex()
if whichProj == 0:
self.maskProjector_1.setFocus(True)
self.maskProjector_2.setFocus(False)
elif whichProj == 1:
self.maskProjector_1.setFocus(False)
self.maskProjector_2.setFocus(True)
焦点不应该激活其中一个窗口并将其移到前面吗?