dennis
8th June 2010, 19:01
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 (http://doc.trolltech.com/qq/qq21-syntaxhighlighter.html):
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextEdit editor;
HtmlSyntaxHighlighter highlighter(editor.document()); // my subclass
editor.show();
return app.exec();
}
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:
QTextEdit *myTextEdit = new QTextEdit();
HtmlSyntaxHighlighter highlighter(myTextEdit->document()); // doesn't do anything
myTabWidget->addTab(myTextEdit, tr("foobar"));
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()
And why doesn't the the syntax highlighter work?
Thanks in advance.
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 (http://doc.trolltech.com/qq/qq21-syntaxhighlighter.html):
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTextEdit editor;
HtmlSyntaxHighlighter highlighter(editor.document()); // my subclass
editor.show();
return app.exec();
}
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:
QTextEdit *myTextEdit = new QTextEdit();
HtmlSyntaxHighlighter highlighter(myTextEdit->document()); // doesn't do anything
myTabWidget->addTab(myTextEdit, tr("foobar"));
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()
And why doesn't the the syntax highlighter work?
Thanks in advance.