Important: Please read the Qt Code of Conduct -

QML TextEdit selectionColor / selectedTextColor when using a QSyntaxHighlighter

  • Hi, I am writing a simple text editor using QML with some basic syntax highlighting delivered from a custom QSyntaxHighlighter class.

    The result looks like this:

    Beautiful! However when I select some text it ends up looking like this:

    As you can see the text all becomes white. I would like the text colour to not change and to retain my syntax highlighting colours but I'm not sure how to do this with a TextEdit.
    I know that the qml TextEdit component has properties for the selection colour (selectionColor) and the selected text color(selectedTextColor) but I see no way to have no selected text colour.

    Hopefully there's an easy way here that I'm missing.

Log in to reply