I am trying to create a QT main window from Java directly using JNI and I get a threading error.
My code looks like this:
Exam category:
test for public class {public static zero main (string ... args) {System.out.println (System.getProperty ("java.library.path")); Testwindows F = new test window (); F.show (); }}
TestWindow class:
public class testwondo {static {System.loadLibrary ("mylib"); } Public resident zero show (); }
C ++ impl:
JNICALL Java_testpackage_TestWindow_show (JNIEnv *, job) by zero {int c = 0; Four ** one = null; QApplication * app = new QApplication (C, A); QMainWindow * mw = New QMainWindow (); Mw- & gt; SetWindowTitle ("hello"); Mw- & gt; Set Glomptary (150, 150, 400, 300); Mw- & gt; Show (); QApplication :: Executive (); }
And I have been painted on my window, but it is frozen (it does not get any events) and the following error message when the QMainWindow provides the object immediately:
QCoreApplication :: sendPostedEvents: can not send the post event to the other thread for the object
I know that all UI operations should be performed in the UI thread but my example I have just made a QApplication in a thread, so, all Some should work properly.
I have done some tests that use the code of my "show" method using QT :: QueuedConnection from a QMetaObject :: invokeMethod but nothing works properly.
I know that I can use zombie ... but I know that it can also be done basically and this is what I want to do :)
Any ideas on this? thank you in advanced!
Ernesto
Just a suggestion *: Maybe you should have a different Instant a native window in thread?
public square test {public static zero main (string ... args) {System.out.println (System.getProperty ("java.library. Path")); New thread (new runnabal) (public run from zero) {testwondo F = new test window (); F. Show ();}}). Start (); }}
* I have never programmed a Java application with a local GUI that you should consider swing or SWF instead?
Another suggestion is to try JNI instead of JNI:
Comments
Post a Comment