|Home | Tutorial | Classes | Functions | QSA Workbench | Language | Qt API | QSA Articles | Qt Script for Applications | ![]() |
This Text Edit example displays a text editor with the user interface written in pure C++.
The example adds the mainwindow of the application as an application object. This makes all the signals, slots and properties of the application's mainwindow and its children scriptable. Please note that this is bad practise for more complex applications, because it makes too much of the application's internal functionality available to script programmers. However, it is a simple solution that may be suitable for some applications.
Text edit also shows how to make a non QObject class available to Qt Script. Consequently, it should be possible for the script writer to implement a syntax highlighter which works on the current editor. Qt already provides a class called QSyntaxHighlighter. To make this class available, we implement a class called SyntaxHighlighter which inherits QObject and QSyntaxHighlighter. We implement an interface (public slots and signals) which makes the class scriptable in the SyntaxHighlighter class.
To allow the script writer to instantiate a syntax highlighter, the class is made available to Qt Script where the class ConstructorFactory inherits QSObjectFactory.
The text edit example already comes with one syntax highlighter implemented in Qt Script. It is called DiffHighlighter and it highlights uniformed diffs.
See also QSA Examples.
Copyright © 2001-2006 Trolltech | Trademarks | QSA version 1.1.5
|