PDA

View Full Version : Show a tooltip on a line edit with NoFocus



dennisvz
18th August 2020, 17:15
Some line edits in my UI have a FocusPolicy set to NoFocus by code at various times 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 QToolTip explaining why the user cannot enter data. I thought about using mousePressEvent, 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 link the line edit to the tooltip function (it does not work):



self.ui.xyz.mousePressEvent(QMouseEvent=self.check _reminder_tooltips)


Is this the way to solve my issue, and if so, what is the correct code? If a tooltip will not work under any circumstance, an alternative would be link to a QMessageBox

dennisvz
18th August 2020, 20:13
SOLVED: Per the advice of an expert, instead of changing the FocusPolicy of the line edit to NoFocus, I used lineEdit.setReadOnly(True), and it works.