PyQt Window Focus
To get window_b
to always stay on top you have to add the windowflag QtCore.Qt.WindowStaysOnTopHint
. In your __init__
add the call
self.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint)
I have to add that this only is a hint to the windowing manager and not guaranteed to succeed.
Uahmed
Currently, I am writing my Master's Thesis in the field of Blockchain Technology. I am working on “Design and Implementation of Decentralized Student Loan Management System using Smart Contracts and Blockchain Technology.” In the thesis, I am studying in depth about the blockchain technology,hyper ledger framework and Smart Contract. I am using Ethereum Blockchain and Solidity/Go language to develop Smart Contract. I will also be making the "dApp" to interact with the blockchain.
Updated on July 18, 2021Comments
-
Uahmed almost 3 years
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 appears, it disables Window A. Now what i want is that whenever the user clicks outside of Window B, it should give focus back to Window B.
Here is the code for Window B:
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.setFocusPolicy(QtCore.Qt.StrongFocus) def focusOutEvent(self,event): self.setFocus(True) self.activateWindow() self.raise_() self.show()
I tried
setFocus
andactivateWindow
, but it didnt give focus back to Window B.Any suggestions?
-
Uahmed over 11 yearsit works for me but it didnt give focus back to window_b now window_b remains always top but no focus .
-
halex over 11 years@user1224233 Ah ok. I read always in focus but my brain made always on top of it :). Sorry
-
Uahmed over 11 yearsany suggestion to give focus to window ?
-
Ophir Carmi over 3 yearswhere in the code in the question do we need to put the line you posted for the problem in the question to be solved?