I inherit a class from QSyntaxHighlighter , override the highlightBlock(const QString&) method highlightBlock(const QString&) , but when I create an instance and pass it to the QTextEdit::document() constructor, the following error pops up when I start the application:

 Debug error Program: C:\Qt\5.8\msvc2013_64\bin\Qt5Cored.dll Module: 5.8.0 File: global\Qglobal.cpp Line: 3070 ASSERT: "uint(i) < uint(size())" in file 

I do everything as it is written in the book but an error pops up, please help me figure out why.

  • You would have shown the class code, otherwise all telepaths became extinct - Bearded Beaver
  • class Hilight: public QSyntaxHighlighter {Q_OBJECT int state; int pos_open; int pos_closed; int start; int end; int index; bool indic; QStringList list; public: Hilight (QTextDocument * wig = 0); protected: virtual void highlightBlock (const QString & str); private: bool is_complicated_comment_open (const QString & str); bool is_complicated_comment_closed (const QString & str); bool is_simple_comment (const QString & str); bool is_string (const QString & str); void highlight (const QString & str, int start, int end); }; - Dmitrii
  • Edit the question by adding code to it, you do not need to add code to the comments - Bearded Beaver
  • This is the header file. - Dmitrii
  • But the implementation of the constructor: Hilight :: Hilight (QTextDocument * par / * = 0 * /): QSyntaxHighlighter (par) {state = 0; pos_open = 0; pos_closed = 0; start = 0; end = 0; index = 0; indic = 0; list << "bool" << "int" << "double" << "float" << "short" << "char" << "foreach" << "for" << "if" << "else "<<" try "<<" catch "<<" true "<<" false "<<" break "<<" continue "<<" return "<<" delete "<<" new "<<" mutable "<<" this "<<" struct "<<" class "<<" union "<<" private "<<" public "<<" protected "<<" virtual "<<" const "<<" switch "; } - Dmitrii

0