Qt Labs Forum » General discussions

  1. Hi!
    I'm trying to get QtJambiAWTBridge working for hours now but I can's see any success!

    I compiled it using Qt-4.4.0 and QtJambi 4.4.0 (both from Source-Package) and SUN's JDK (build 1.6.0_06-b02 64 Bit) on my Gentoo AMD64-System. Compiling worked fine! The only thing I had to do is to adapt the LIBS-var in the Makefile to locate libjawt correctly.

    For running my examples with QtJambiAWTBridge I had to include the path to libjawt.so (I also had to link it to liblibjawt.so.so because QtJambiAwtBridge.jniLibraryName( String ) wants it like that) and to motif21/libmawt.so into Jambi's native library path (Eclipse Project Settings/Java Build Path/Libraries/Jambi_Location/Native Library Location).

    My little Java-Example looks like this (my goal is to integrate the Apache Batik SVG-Toolkit eventually):

    
    public class test extends QWidget{
        public static void main(String[] args) {
            QApplication.initialize(args);
            test app = new test(null);
            app.show();
            QApplication.exec();
        }
    
        public test(QWidget parent){
            super(parent);
            QGridLayout layout = new QGridLayout( this );
            QComponentHost b = new QComponentHost( new Button( "push me!" ) );
            layout.addWidget( b );
        }
    }
    

    (Trying it with your example "AwtInQt" brought exactly the same result)

    Result:
    Application start without any error messages or warnings but the ComponentHost is shown outside my Application window. (It stays in the upper left corner of the screen). Resizing my app-Window causes the ComponentHost also to be resized. But in the app-Window where this ComponentHost actually should be placed a part of my screen is shown disturbedly.

    I found out that in QtJambiAwtBridge.RedirectContainer.paint( Graphics ) the following native Library method gets called once:
    QtJambiAwtBridge.attach(this, host.nativeId(), false)
    (this method returns true in spite of the Component obviously not being attached)
    However this method is implemented in qawtintegration.cpp not in qawtintegration_x11.cpp. Therefore I tried to run QtJambiAwtBridge.attachComponent( this, host.nativeId() ) instead which results in the following exception:

    
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
    	at java.awt.Container.addImpl(Container.java:1022)
    	at java.awt.Container.add(Container.java:352)
    	at com.trolltech.research.qtjambiawtbridge.QtJambiAwtBridge.attachComponent(Native Method)
    	at com.trolltech.research.qtjambiawtbridge.QtJambiAwtBridge.access$0(QtJambiAwtIntegration.java:159)
    	at com.trolltech.research.qtjambiawtbridge.QtJambiAwtBridge$RedirectContainer.paint(QtJambiAwtIntegration.java:101)
    	at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
    	at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
    

    I don't have any idea how to solve this because changing the superclass of RedirectContainer to Panel instead of Frame does also not have the wanted effect.

    Any Ideas?

    PS: When I started this experiment there was also a problem with locking the JAWT_DrawingSurface ("Couldn't lock drawing surface" in qawtintegration_x11.cpp around line 44). The lock method permanently returned JAWT_LOCK_ERROR. I absolutely cannot understand why but this error disappeared suddenly after a reboot of my system.

    Posted: 3 months #
  2. Hi!
    I've got new hints on the problem! I started and stopped the application (using QtJambiAwtBridge.attach(this, host.nativeId(), false) again) about ten times and then, the thenth time i ran it it worked correctly. Trying on I found out that it works approximately in one of three to nine cases.

    I guess this problem could be caused by a bug in X11. The call to "XReparentWindow(awtDisplay, awtWindowId, qtWindowId, 0, 0)" in qawtintegration.cpp always returns 1 regardless if attaching worked or not. Maybe the problem resides there or where WindowId's are retrieved. But what would be a solution for this?

    Thanks in advance
    Tom

    Posted: 3 months #
  3. Hi, Tom.

    I don't have any solution for you right now, but I'll look into this. I have noticed some random failures on Linux as well, but I haven't been able to narrow it down. There should be some updates to this project in the near future, and I'll blog about it once I have something concrete to say. Until then, please let me know if you come across any other symptoms.

    Posted: 3 months #

RSS feed for this topic

Reply

You must log in to post.



© 2008 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners.