Archived

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

Ice & Qt

Hi All,

Weird - I did a search for Qt which returned no results, yet I stumbled upon a message from 2003 about Ice & Qt from Google I think. Maybe the forum search doesn't look that far back?

Anyway, the response to the original post was that there is no problems using Ice and Qt. Is this still the case with Qt4.1 and Ice3.0?

I am trying to get to grips with Ice and trying to understand it but in the mean time, I am wondering how Ice works with Qt types such as QString. Bearing in mind I am not sure how Ice deals with any custom types yet! - I am still trying to figure that out...

Comments

  • xdm
    xdm La Coruña, Spain
    Hello paul

    there aren't know problems using Qt-4.1 and ice

    Ice not handle QString it only handle slice define types you must use string
    that are maped to std::string in c++, QString have convenient functions to convert fron/to std::string
  • It would be nice if ICE provided a way to use QStrings by default instead of std::string. Is it possible to affect what the ICE compiler produces when it sees "string" in the ICE file?
  • marc
    marc Florida
    It would be nice if ICE provided a way to use QStrings by default instead of std::string. Is it possible to affect what the ICE compiler produces when it sees "string" in the ICE file?

    Sure, this would be possible. If you have a commercial need for such a feature, please contact us at info@zeroc.com.
  • Only if I have a commerical need? :)

    At the moment, I am just tasked with looking around and there is very little chance even Qt will be adopted (mainly because non of the managers have heard of it - they live in a M$ world!).

    I was just wondering if ICE already supports the feature to be able to control the output of the compiler, but I realise (now I've had time to think) that it's probably a case of writing a specific Qt version of the compiler. Is that correct?

    Essentially, what I am trying to say is: Can ICE do this *now*, not in a future release.
  • marc
    marc Florida
    No, Ice cannot do this now. We wouldn't use a special compiler, but metadata. For example, we use metadata to make use of the new Java generic types. See:

    http://www.zeroc.com/faq/javaGenericTypes.html

    I'm afraid without a commercial customer who needs this, there is very little chance that we support Qt strings in Ice.
  • As mentioned on the Qt mailing list, the type conversion between STL and Qt is quite easy using the new QString/ QMap/ QList functions, e.g. for QString:

    fromStdString(), toStdString()

    What's more nasty is that you have two threading environments in C++/ Ice/ Qt, i.e. QThreads and Ice::Util::Thread. Sometimes it's really a bit awkward to decide which thread classes to use.

    But anyway, this is also not a big problem, so programming in Qt along with ZeroC Ice on both client and server-side is generally really smooth.

    The only thing is that the UI thread usually is blocked when performing synchronous calls. I guess there was a posting on this before, but unfortunately I can't find it.

    Stephan
  • xdm
    xdm La Coruña, Spain
    You can read this thread for more info of QT adn ice http://zeroc.com/vbulletin/showthread.php?t=762
  • Yes, you are right. Thanks for the pointer. However, integration through something like a worker thread is really tedious (as mentioned in the other thread). Did anyone inspect Qt 4.x if the new event handling model would allow smoother "non-UI-refresh-blocking-Ice-proxy-calls" ?

    Stephan
  • Weird - I did a search for Qt which returned no results, yet I stumbled upon a message from 2003 about Ice & Qt from Google I think. Maybe the forum search doesn't look that far back?

    I reconfigured our database to allow also two-letter word searches. So you can now search for "Qt" :)
  • stephan wrote:
    As mentioned on the Qt mailing list, the type conversion between STL and Qt is quite easy using the new QString/ QMap/ QList functions, e.g. for QString:

    fromStdString(), toStdString()

    So, just to get this clear, if I have an existing class in my app, lets say a DisplayObject:
    struct DisplayObject
    {
      QPoint point;
      QString string;
    };
    

    The only way I can pass this object around in ICE methods is to create a seperate object in an ice file:
      struct DisplayObjectICE
      {
         int x;
         int y;
         string name;
      }
    

    Then do conversions from DisplayObjectICE to DiplayObject and vice-versa. Is that the case?
  • benoit
    benoit Rennes, France
    Hi Paul,

    Yes, this is correct. You need to define in Slice the types that you want to use in the methods of your Slice interfaces. You can't use existing types defined with your favorite programming language as Ice doesn't know how to marshal/unmarshall these types.

    Cheers,
    Benoit.
  • So I assume supporting Qt would be a case of modifying slice2cpp at the code level, the result of which might be a different program (ie slice2qt).
  • dwayne
    dwayne St. John's, Newfoundland
    Hi,
    So I assume supporting Qt would be a case of modifying slice2cpp at the code level, the result of which might be a different program (ie slice2qt).

    Yes, adding support for Qt types in Ice would require modifying slice2cpp. This would be done by enhancing the metadata support that slice provides. For example, in java, you can specify the type to use for sequences. By default IceJ will use a plain array, but though metadata you can specify an alternate type for the sequence such as a LinkedList or ArrayList. The data passed over the wire remains the same but the types presented in the user code changes to the type specified.

    Having said that, we have no current plans to add such support for Qt types. Of course if you are interested in financing such a change, please contact sales@zeroc.com.

    Regards,
    Dwayne
  • I've been using Ice to marshall some Qt types, and doing it by hand isn't all that difficult (using QString::fromStdString, etc).

    If you have more sophisticated classes that you need to marshall, I think it would be pretty easy to write your own marshallers using QDataStream.

    I haven't needed to do that thus far, but may do it sometime soon.
  • matthew
    matthew NL, Canada
    Note that passing serialized data as a byte-stream over the wire as opposed to defining slice types generally a bad idea since it means you need to have Qt at either end to understand the data.