|
|
DaoQt: A Binding to Qt Application and GUI FrameworkThe official documentation of Qt4.5 can be found here: Qt Reference Documentation . With DaoQt module, it is possible to access most of the functionalities of the excellent Qt application and GUI framework. Most of the Qt classes and functions are wrapped as they are, with the same class inheritance relationships and similar function prototypes. However due to the limit of the autobind tool used to generate the bindings, there are several issues one needs to know. These issues will be explained bellow. (This module is released under LGPL!)
load DaoQtCore;
load DaoQtGui require DaoQtCore; app = QApplication( 'Hello World!' ); lab = QLabel( 'Hello World!' ); lab.resize( 300, 200 ); lab.move( 200, 200 ); lab.show(); app.exec();
Using DaoQt, the signals and slots can be connected freely between native Qt objects and objects of derived classes in Dao.
In most cases, if QString is used as parameter or returned value in a function, it is automatically converted to Dao string type when wrapping this function. But if it is used as a pointer, it will not be convered automatically. So for a Qt function with the following prototype:
QString qt_func( const QString & p1, QString *p2 );
It will be wrapped as,
qt_func( p1 : string, p2 : QString ) => string;
To use the functionalities of QString, a QString object must be constructed explicitly by calling its constructor, e.g.
s1 = QString( 'hi' );
s2 = QString( 0x66 ); For the methods of the QString class, if the returned value is QString, it is not converted automatically. For example,
QString& QString::append(const QString &s);
will be wrapped as,
append( self : QString, s : string )=>QString
So it will still allow user to write codes like
QString( 'abc' ).append( 'def' ).append( 'gh' );
To convert from QString to Dao string, one can use toLocal8Bit() Similarly, in DaoQt, QChar is converted to int, and QByteArray is converted to Dao string.
Most of the QList<X>, QList<X*>, QVector<X>, and QVector<X*> are converted to list<X>, when they are used as parameters or returned values.
The operators of QTextStream are not wrapped, but several methods are added for writing data to the stream.
write( self : QTextStream, data : int )=>QTextStream
write( self : QTextStream, data : float )=>QTextStream write( self : QTextStream, data : double )=>QTextStream write( self : QTextStream, data : string )=>QTextStream write( self : QTextStream, data : any )=>QTextStream The QFile.close() must be called when it is done.
view count 1064 times
created at 2009-06-27, 10:49 GMT modified at 2009-06-27, 12:37 GMT |
fu: Many thanks (Jul.04,04:29) klabim: fixed Hi, great, now my test works now :- ). (Jun.30,17:51) Nightwalker: Few suggestions (Jul.03,14:37) |