I have an issue with setting focus on one of four child windows from a main window. I tried setFocus to one of the four, but the main window still keeps the focus. I have a combo box that lets you choose which of the four windows to bring into focus. Each of the widows is on a separate monitor.
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)
shouldn't the focus activate one of the windows and move it to front ?