3

What I am trying to do is make an on screen keyboard. To do this I need to stop the Program from taking focus away from other windows. Here is the code I have that keeps the window on top.

import sys
from PyQt4 import QtGui, QtCore, Qt
class mymainwindow(QtGui.QMainWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self, None, QtCore.Qt.WindowStaysOnTopHint)
app = QtGui.QApplication(sys.argv)
mywindow.show()
app.exec_()

(Note: Example from Keep Window on Top) So what I want to do is add code to stop the window taking focus.

Thanks

Community
  • 1
  • 1

1 Answers1

2

Change focus policy of window and all of its contents QWidget::setFocusPolicy

Kamil Klimek
  • 12,884
  • 2
  • 43
  • 58
  • I have tried using the setFocusPolicy with it set to NoFocus, Are you able to provide a example please? Thanks –  Feb 03 '11 at 01:26
  • Remember that you need to do it for ALL controls. QPush/Tool/OtherButton has default policy different than NoFocus – Kamil Klimek Feb 04 '11 at 09:51