[Kde-java] Compressed Icons in Java Apps created with juic

Lukas Molzberger lukas.molzberger at ais.fraunhofer.de
Wed Aug 18 17:18:22 CEST 2004


Am Mittwoch, 18. August 2004 14:04 schrieb Richard Dale:
> On Wednesday 18 August 2004 12:35, Lukas Molzberger wrote:
> > Hi,
> >
> > > Could you post the .ui file to make it easier to test out the problem?
> >
> > Sure, I'll send you the .ui file.
>
> Yes, thanks for sending me that..
>
> > In the meantime I've got yet another problem. Perhaps you know a solution
> > for that problem too. The app that I'm writing contains a few operations
> > that may take a long time to process and therefore I had to use Java
> > threads to keep the ui from blocking.
>
> Another way to break up long term operations is to use a single thread with
> QTimers - each long term operation does something for say 100 ms, then
> exits setting a QTimer again ready for another 100 ms of processing once
> the other operations have had a chance. This assumes that the work can be
> split up into discrete chunks though. 
Hmm, I guess this would be possible, but it wouldn't be a nice solution for 
this problem. I need to define a clean api for the processing part of my 
program so that this part can be easily be used in other applications too. 
However, with this method I would have to define a way in the api on how to 
leave and reenter the processing part. I really would like to avoid that.

> Or perhaps just fork() and exec() a 
> subprocess to run in the background.
I guess fork wouldn't make much of a difference to threads here, since I still 
would have to post an event to the ui process, so that the result of the 
processing could be shown in the ui. 
>
> > So I have one thread for the ui and
> > one thread for the actual processing and I use a working queue to get the
> > commands from the ui to the processing thread. So far everything works
> > very well, but what I still need is a way to inform the ui that
> > processing has finished and that the ui needs to be updated. According to
> > the Qt docs the way to do this is to call
> >
> > QCustomEvent ce = new
> > QCustomEvent(ClassifierThread.FINISHED_IMPORT_CORPUS);
> > QApplication.postEvent( qmainwindow, ce );
> >
> > in the processing thread and to have a method
> >
> >    protected void customEvent(QCustomEvent e) {
> >      System.exit(0);  // Exit just for testing
> >    }
> >
> > as part of the QMainWindow object. The problem is that while
> > QApplication.postEvent( qmainwindow, ce ); definitely gets called, the
> > event handler customEvent however doesn't get called. Do you have any
> > idea?
>
> I'm not sure if you can mix java threads and Qt threads like this. I think
> that's more likely to be the problem than the QMainWindow.customEvent()
> method being wrong. 
It's possible that Java threats can't be used in conjunction with Qt, but now 
I've tried to send a custom event from within the same process and that also 
didn't worked. I've attached the test code to this email. What it basically 
does is, it calles QApplication.postEvent( this, ce ); when you hit the 
button. Then the method:
    protected void customEvent(QCustomEvent e) {
//		System.exit(0);
		System.out.println("Received a custom event!");
    }
should have been called, but that never happens. 
I have no idea why that doesn't work. 

> Is there a Qt event logging mechanism that could be 
> turned on to track how the custom event gets lost?
Hmm, I don't know, is there such a thing in Qt? So far I've used println and 
exit calls to check whether the event has been processed or not.
 
>
> In QMainWindow.cpp there is a custom event handler for overriding
> customEvent() and it looks just the same as the other event handlers:
>
>  void customEvent(QCustomEvent* arg1) {
>   if (!QtSupport::eventDelegate(this,"customEvent",
> (void*)arg1,"org.kde.qt.QCustomEvent")) {
>    QObject::customEvent(arg1);
>   }
>   return;
>  }
>

Cheers
Lukas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PostEvent.java
Type: text/x-java
Size: 3241 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-java/attachments/20040818/5678507f/PostEvent-0001.bin


More information about the Kde-java mailing list