Home Help Center

Are there any sample apps using Qt?

rpetersrpeters Member Rich PetersOrganization: braxton technologyProject: cross platfrom JNI replacement ✭✭
I have searched for sample code with demonstrates using Qt. I have not found any that addresses using Qt as the server or as a Qt Service. Can this be done? I would like to know how to handle the dispatching issue. It doesnt seem like calling waitForShutdown() will work in this case.

A sample app would be very helpful.

Comments

  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    It is not necessary to call waitForShutdown in order to have calls dispatched by Ice. It is just a convenience function that we provide to allow application to wait for the communicator shutdown, which is often desired for simple applications. However, Ice is able to handle requests as soon as you activate your object adapters and will continue to do so until you either deactivate them or destroy the communicator.
  • rpetersrpeters Member Rich PetersOrganization: braxton technologyProject: cross platfrom JNI replacement ✭✭
    Qt Sample

    Thanks,

    that was not clear to me.



    Is it possible to use the QtService class with Ice instead of IceService? Or would it be better to use IceService vis QtService?

    I would really like to see a sample server that uses Qt, if there is one?

    regards
    Rich
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Rich,

    The Ice::Service class is only a convenience class, and there is no obligation for you to use it. You might want to review the source code for this class to see exactly what it does for you. I don't have personal experience with Qt but I expect that you would have no problems using the QtService class with Ice. You just need to follow the usual Ice conventions and make sure that you destroy your communicator before the main thread exits.

    Given that the server is a graphical program, you'll also need to ensure that you follow the Qt guidelines for updating the UI in a multi-threaded application, although you're probably already aware of these restrictions. Matthew wrote a four-part series of articles about integrating Ice with Qt, beginning in issue 12.

    Regards,
    Mark
  • rpetersrpeters Member Rich PetersOrganization: braxton technologyProject: cross platfrom JNI replacement ✭✭
    Thanks,

    for some reason (probably because they are pdf) the newletters arent searched when you search the forums or your website.
  • dwaynedwayne St. John's, NewfoundlandMember Dwayne BooneOrganization: ZeroC, Inc.Project: Internet Communications Engine
    One thing to note about Matthew's articles is that when they were written it was possible for AMI calls to block during DNS lookup or connection establishment. Since then we have made changes that guarantee that AMI calls are always non-blocking and thus affect some design decisions when integrating with GUI.
  • mefostermefoster Member Mary Ellen FosterOrganization: Heriot-Watt University, EdinburghProject: ECHOES learning environment ✭✭✭
    I've written several servers that had to combine waitForShutdown() with another external event loop. What I usually ended up doing was something like this (Java-esque pseudocode):
    // Initialise Ice
    // Initialise other stuff
    Thread t1 = new Thread(
        waitForShutdown();
    );
    Thread t2 = new Thread(
        // wait for other event loop to end
    );
    
    t1.start();
    t2.start();
    
    while (t1.isRunning() && t2.isRunning()) {
        sleep (250); // Or whatever
    }
    
    if(t1.isRunning()) {
        communicator.destroy();
    }
    if(t2.isRunning()) {
        // Stop the other event loop
    }
    

    This worked well in practice ...

    MEF
Sign In or Register to comment.