Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to get QSyntaxhighlighter's format outside?



  • I use QSyntaxHighlighter's subclass to highlight text, but when i use
    QTextFormat format = cursorForPosition(event->pos()).charFormat()
    in QPlainTextEdit::mousePressEvent, the format always is default.
    So I search for a way to get the format which apply in highlighter.(QSyntaxHighlighter::formatis protected...)
    help!!!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Out of curiosity, why do you need that information like that ?