[Kde-java] QSizePolicy

Richard Dale kde-java@kde.org
Sat, 25 Jan 2003 05:25:00 +0000


On Friday 24 January 2003 2:00 pm, Marco Ladermann wrote:
> Hi all,
>
> 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.

The virtual method callbacks to the polish() methods are missing, and the uic 
generated code overrides those. That was something I was meaning to fix.

> While translating the <sizepolicy> tag and its
> <horstretch> and <verstretch> subtags I encountered the problem that the
> designer uses numeric characters as content of those tags. I looked up the
> Qt reference and found the method signature (C++):
>
> QSizePolicy
> 	setHorStretch( uchar )
> 	setVerStretch( uchar )
>
> in Java
> 	setHorStretch( String )
> 	setVerStretch( String )
>
> Indeed this methods are implemented as
>
> <code>
> JNIEXPORT void JNICALL
> Java_org_kde_qt_QSizePolicy_setHorStretch(JNIEnv *env, jobject obj, jstring
> sf)
> {
> static QCString * _qstring_sf = 0;
> 	((QSizePolicy*) QtSupport::getQt(env, obj))->setHorStretch((uchar)
> QtSupport::toCharString(env, sf, &_qstring_sf));
> 	return;
> }
>
> JNIEXPORT void JNICALL
> Java_org_kde_qt_QSizePolicy_setVerStretch(JNIEnv *env, jobject obj, jstring
> sf)
> {
> static QCString * _qstring_sf = 0;
> 	((QSizePolicy*) QtSupport::getQt(env, obj))->setVerStretch((uchar)
> QtSupport::toCharString(env, sf, &_qstring_sf));
> 	return;
> }
> </code>
>
> in qtjava/QSizePolicy.cpp, but QtSupport::toCharString returns char* and
> I'm wondering if this cast to uchar is correct?  Okay, I think it will not
> crash, but neither do any usefull ;-).
Oops - this is totally wrong - not useful at all! I've changed the uchars to 
map onto java shorts in both the HEAD and KDE_3_1_BRANCH branches of the 
qtjava project.

-- Richard