My code sometimes sets the FocusPolicy of some QLineEdits to NoFocus to prevent data from being entered. When a user clicks on a NoFocus line edit (to try to key in data), I would like to show a message explaining why the user cannot enter data. QToolTip (which is what I would like) does not work because the line edit has NoFocus.
I thought about using mousePressEvent to trigger a tooltip, but am unsure if it would work (because of the NoFocus issue) but even if it would work, am unsure how to code linking the line edit to the function that shows the tool tip. My attempt to code a mouse event (does not work).
self.ui.xyz.mousePressEvent(QMouseEvent=self.check_reminder_tooltips)
Can a message (tooltip or otherwise) be shown when user clicks/hovers over a NoFocus line edit?
If you want the user to not be able to write to the QLineEdit
then just set the readOnly
property to true:
le.setReadOnly(True)