Hi,
First of all I need to say that I'm very new to Qt and C++ so there is a lot I still don't understand with the language.
Anyhow I'm trying to insert a syntax highlighter for QTextEdit and it works if I follow this tutorial:
int main(int argc, char *argv[])
{
HtmlSyntaxHighlighter highlighter(editor.document()); // my subclass
editor.show();
return app.exec();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextEdit editor;
HtmlSyntaxHighlighter highlighter(editor.document()); // my subclass
editor.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
However I want to apply this highlighter to my QTextEdit in my QTagWidget and the only way I can find to insert a QTextEdit is like this:
HtmlSyntaxHighlighter highlighter(myTextEdit->document()); // doesn't do anything
myTabWidget->addTab(myTextEdit, tr("foobar"));
QTextEdit *myTextEdit = new QTextEdit();
HtmlSyntaxHighlighter highlighter(myTextEdit->document()); // doesn't do anything
myTabWidget->addTab(myTextEdit, tr("foobar"));
To copy to clipboard, switch view to plain text mode
So whats the difference between between these two declarations?
QTextEdit *myTextEdit
= new QTextEdit();
// now I need to use: myTextEdit->publicFunction()
QTextEdit editor;
// now I need to use: myTextEdit.publicFunction()
QTextEdit *myTextEdit = new QTextEdit(); // now I need to use: myTextEdit->publicFunction()
QTextEdit editor; // now I need to use: myTextEdit.publicFunction()
To copy to clipboard, switch view to plain text mode
And why doesn't the the syntax highlighter work?
Thanks in advance.
Bookmarks