Spell checking for QLineEdit – Is it possible?
-
Hi,
is there a way to add spell checking to
QLineEdit
?I know that
QTextEdit
can be made to look like a single-line input by setting its height to around 25 pixels and interceptingkeyPressEvent
to blockQt.Key_Enter
andQt.Key_Return
. But honestly, that feels like a bit of a hack.Is there are more straightforward solution?
Any suggestions are appreciated!Peter
-
@PtSl
As per GooglingQLineEdit spell check
there is nothing supplied. Other people seem to have added this, e.g. https://blog.ssokolow.com/archives/2022/07/22/a-qlineedit-replacement-with-spell-checking/ but apparently by putting it on aQPlainTextEdit
and then making that look like a single lineQLineEdit
. Which seems to be about where you are at. If there were a "more straightforward solution" for aQLineEdit
I would expect to have found it. If you are going to write your own code to intercept key presses on aQText[Plain]Edit
and deal with spellchecking I can't see why you couldn't do that on aQLineEdit
if that is what you want to stick to, but have not looked into it.P.S.
Now that you have posted what you would like, I'm not at sure you would get "red squiggly underlines" inQLineEdit
.QTextEdit
at least supports HTML, but I don't thinkQLineEdit
does. So one would assume that at least would require interceptingpaint()
to achieve the visuals, apart from the character-typing-intercepting and spell-check itself. -
@Pl45m4 said in Spell checking for QLineEdit – Is it possible?:
Yes, but this too says
To check spelling in a QTextEdit or QPlainTextEdit, proceed as follows:
I have not looked, but has it been written to allow for a
QLineEdit
? Or are we accepting that OP must change toQ[Plain]TextEdit
?and read through a related topic here
I had seen that but it didn't get very far.... And it's MacOS only.