Spell checking for QLineEdit – Is it possible?
-
Hi,
is there a way to add spell checking to
QLineEdit?I know that
QTextEditcan be made to look like a single-line input by setting its height to around 25 pixels and interceptingkeyPressEventto blockQt.Key_EnterandQt.Key_Return. But honestly, that feels like a bit of a hack.Is there are more straightforward solution?
Any suggestions are appreciated!Peter
-
Hi,
is there a way to add spell checking to
QLineEdit?I know that
QTextEditcan be made to look like a single-line input by setting its height to around 25 pixels and interceptingkeyPressEventto blockQt.Key_EnterandQt.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 checkthere 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 aQPlainTextEditand 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 aQLineEditI would expect to have found it. If you are going to write your own code to intercept key presses on aQText[Plain]Editand deal with spellchecking I can't see why you couldn't do that on aQLineEditif 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.QTextEditat least supports HTML, but I don't thinkQLineEditdoes. So one would assume that at least would require interceptingpaint()to achieve the visuals, apart from the character-typing-intercepting and spell-check itself. -
Hi,
is there a way to add spell checking to
QLineEdit?I know that
QTextEditcan be made to look like a single-line input by setting its height to around 25 pixels and interceptingkeyPressEventto blockQt.Key_EnterandQt.Key_Return. But honestly, that feels like a bit of a hack.Is there are more straightforward solution?
Any suggestions are appreciated!Peter
-
Hi,
it's built for Qt5 but you could try
and read through a related topic here
Maybe a
QValidatorwith a dictionary linked to it also helps@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.

