Archived

This forum has been archived. Please start a new discussion on GitHub.

QT Problems

I wrote a Programm with an Gui on the client-side, created by QT.
This Gui has two Buttons ("Hello" and "Shutdown") an a textBrowser-Field.
If I press the Hello-Button, the Server prints an hello message on stdout.
If I press the Shutdown-Button, the Server shutdowns.

What I now want, is to show the hello message in the textBrowser-Field.

How I can do this.

As an attachment, I send my code to you

greetings Peter

Comments

  • xdm
    xdm La Coruña, Spain
    Hi Peter,

    In your demo you use a Callback class to call sayHello and sayShutdown asynchronous from a queue, i think you get this approach from and old demo Matthew wrote about integrating Ice with Qt, this approach was necessary previous to Ice-3.3.1 because there were some scenarios where asynchronous call could end blocking the UI thread, Since Ice-3.3.1 this has changed and asynchronous calls are warranted to never block the calling thread.

    So i will suggest you should use AMI for made all your calls from the UI thread, if you want to update the text Field when the request has been send you could do that from the AMI callback implementation, note that the AMI callback doesn't run in the UI thread so you cannot modified UI components directrly from there, you should use QApplication::postEvent to send and event to the UI thread and update the text field when the UI thread received the event.

    You could found an example of QApplicatin::postEvent used in this way here http://www.zeroc.com/forums/help-center/762-ice-thread-gui-qt.html

    Hope this help, let us know if you need further help
    José
  • ...

    Thank you!

    At first I have to learn more about AMI of Ice, postEvent and customEvent of QT.
    Could you show me a small Example or say to me, where I can find a small example about
    using postEvents and customEvents in QT??

    greeting
    Peter
  • Qt

    Could somebody show me or tell me, where I can find a short example about using postEvent and custonEvent as to my previous QT-Problem?

    greetings
    Peter
  • xdm
    xdm La Coruña, Spain
    Hi Peter,

    I have attached a qt hello demo that shows how to use QApplication::postEvent with Ice.

    To build the demo
    tar zxvf hello.tar.gz
    cd hello
    qmake
    make

    Hope this made the things clear to you,
    José
  • hi

    Thank you very much

    Peter
  • The Qt library is an excellent choice, especially with its recent adoption of the LGPL license! Perhaps Ice will follow?

    Pete
  • xdm wrote: »
    So i will suggest you should use AMI for made all your calls from the UI thread, if you want to update the text Field when the request has been send you could do that from the AMI callback implementation, note that the AMI callback doesn't run in the UI thread so you cannot modified UI components directrly from there, you should use QApplication::postEvent to send and event to the UI thread and update the text field when the UI thread received the event.

    As an alternative and more "Qt-style" way you can consider using signal/slots mechanism with queued connections. In this case signals could be emitted from different thread. Here is an excerpt from the documentaion: "With queued connections, the slot is invoked when control returns to the event loop of the thread to which the object belongs. The slot is executed in the thread where the receiver object lives."

    Regards,
    Andrey.
  • matthew
    matthew NL, Canada
    I discuss these queued signals my article in in issue15 "Integrating Ice with a GUI". The demo that accompanies the distribution uses this technique. As previously noted, as of Ice 3.3.0 you no longer need to worry about AMI blocking the main thread so ignore that part of the demo :)
  • Does not work for me.

    I've been trying to make this example work and did not succeed so far.
    Is this intended to work with the "hello" server example?
    I always get the following error in the client QT widget:

    ../ICE/Install/Ice-3.4.0/include/IceUtil/Handle.h:46: IceUtil::NullHandleException

    I'm using QT 4.5.3 on Linux 64 bit compiled with GCC 4.2.2
    I compiled Ice with the same compiler (64 bit version).

    Please help! :confused:
    Thanks
    Marcel
  • dwayne
    dwayne St. John's, Newfoundland
    One thing you can do is run your application with --Ice.NullHandleAbort. With this property set your application will abort rather than throw an exception when you try to access a null handle, and you will thus be able to see in a debugger where exactly it is occurring which may make it easier to determine what the problem is.
  • Fixed

    Thanks,
    that helped.
    Marcel
  • QT and Ice on the Server side

    Hi all,
    I need to create the dual prototype where I have a QT 3.3 application with a Tcl command line running in the main QT thread. I want to create an Ice server for this application to be able to remotely control/probe it.
    Is there a way to mingle the QT/Tcl and Ice event loops, like having a handle on Ice socket events?
    Or they have to run in 2 separate threads and communicate thru QT custom events?
    Is there a better way with QT4?
    Thanks
    Marcel