Trying to implement what you suggested in last paragraph:
in init:
self.ui.BTFE.installEventFilter(self)
self.ui.BTFE.installEventFilter(self)
To copy to clipboard, switch view to plain text mode
def eventFilter(self, source, event):
if event.
type() == QtCore.
QEvent.
MouseButtonPress and source.
isReadOnly: self.ui.BTFE.setToolTip('Cannot enter data here')
QTimer.
singleShot(5000, self.
remove_tooltip) return super(UIMainWindow, self).eventFilter(source, event)
def remove_tooltip(self):
self.ui.BTFE.setToolTip('')
def eventFilter(self, source, event):
if event.type() == QtCore.QEvent.MouseButtonPress and source.isReadOnly:
self.ui.BTFE.setToolTip('Cannot enter data here')
QTimer.singleShot(5000, self.remove_tooltip)
return super(UIMainWindow, self).eventFilter(source, event)
def remove_tooltip(self):
self.ui.BTFE.setToolTip('')
To copy to clipboard, switch view to plain text mode
I cannot figure out the pyqt code for "showing" and 'hiding" the tooltip -- I only know how to code .setTooltip, but that does not show the tip when the line edit is clicked -- only when hover. Plus, not sure if QTimer will do what I want. Ultimately, I'll have nine line edits that I need to test, all with the same tool tip. thanks
Bookmarks