[Kde-java] QSizePolicy

Marco Ladermann kde-java@kde.org
Sat, 25 Jan 2003 13:53:01 +0100

On Samstag, 25. Januar 2003 06:25, Richard Dale wrote:
> On Friday 24 January 2003 2:00 pm, Marco Ladermann wrote:
> > I'm  on the way to develop XSLT stylesheets to generate Java from
> > Qt-designer's UI files.
> Sounds interesting - I was going to hack to uic to generate java instead of
> C++. I hadn't thought of doing something clever with stylesheets to do it.
> It would certainly be a big improvement if it was possible to use Qt
> Designer with QtJava.

Last year I tried to get your patch to uic running, but I couldn'd manage it 
in a convincing way. For this reason and because one might patch uic anew for 
every new release of uic, I thought it would be better to try another 
approach. Finally I decided to give XSLT a chance, because it is platform 
independend (another alternative would be Velocity at 
http://jakarta.apache.org/velocity, but that needs java)

In the long term it should be possible to generate any language for which 
there exists a binding, but for the moment I'll be happy to get arround those 
nasty little bugs in the XSLT processors (xsltproc, xalan, saxon), the poor 
documentation of the UI file format and some incompatibilities between the Qt  
C++-classes and the Java-classes (see below).

When I have something running that is worth publishing, I will publish the 
code here to discuss and improve it. The timeframe for this depends on my 
ability to convince my company (or at least my department), that QtJava is a 
serious alternative to Visual Basic and Java/Swing (I'm so far the onlyone to 
use a KDE-box  on the desktop). If this succeeds, I expect to have something 
in two or three weeks. If not, then I can only work at home and it will take 
definitively longer.

BTW: Your anouncement to put win dll's of the QtJava bindings on SF was a big 
plus for my argumentation pro QtJava in my company.

And now to something completely different!

QSizePolicy (C++) has a constructor
QSizePolicy ( SizeType hor, SizeType ver, uchar horStretch, uchar verStretch, 
bool hfw = FALSE )

which is not defined in the Java proxy. Therefore I had to change the uic 
approach from

    setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, 
(QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWid
th() ) );

to something like:
        QSizePolicy cwSizePolicy = new QSizePolicy();
        cwSizePolicy.setHorData( 3 );
        cwSizePolicy.setVerData( 5 );
        cwSizePolicy.setHorStretch( 0 );
        cwSizePolicy.setVerStretch( 0 );
        cw.setSizePolicy( cwSizePolicy );

This is of course no problem, as long as every "property" class has a noarg 
constructor, otherwise I have to introduce handling for special cases :(.