Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

mousePressEvent and startSystemResize breaks mouse focus on window?



  • Something weird I found while experimenting. If you use startSystemResize on mouse press, the window "loses" mouse focus. In the example if you activate the resize function by clicking the background, then you release mouse button, the push button will not show tooltip, line edit won't change cursor to IBeamCursor etc. until you press anything again.

    import sys
    from PySide6 import QtWidgets, QtCore
    
    class Window(QtWidgets.QWidget):
    	def __init__(self):
    		super().__init__()
    		self.button = QtWidgets.QPushButton()
    		self.button.setToolTip("Tooltip")
    		self.lineedit = QtWidgets.QLineEdit()
    		self.layout = QtWidgets.QHBoxLayout(self)
    
    		self.layout.addWidget(self.button)
    		self.layout.addWidget(self.lineedit)
    		self.show()
    	def mousePressEvent(self, event):
    		self.windowHandle().startSystemResize(QtCore.Qt.TopEdge|QtCore.Qt.LeftEdge)
    if __name__ == "__main__":
    	app = QtWidgets.QApplication(sys.argv)
    	window = Window()
    	sys.exit(app.exec_())
    

    is there a way to reactivate this "focus"


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    That is indeed something strange but why are you using it in the first place ? QWidget already has support for resizing.