From: Arturo Bonechi Date: 2010-11-22T00:05:32+09:00 Subject: Re: Qt-Ruby implementation of the "Address Book Example" Stefano Crocco wrote in post #962925: > Yes, using an array here is correct. Everytime you see a collection > looking > like a list in C++ (for example, whenever they use QStringList), you > need to > replace it with an array in qtruby Ok, thank you. > I don't think you can do that. It seems that neither QHash nor QMap are > implemented in qtruby, and passing a native ruby hash doesn't seem to > work. In my opinion, being restricted to using C++ types is one of the > most serious weaknesses of qtruby. In your case, I think the best option > would be to declare both signal with a string argument, then convert the > hash to a string (using Marshal or YAML) before emitting the signal and > converting it back in the slot. So, I suppose that I need to do this conversion with arrays too... If that is the price to pay it's Ok for me. > No, it's another limitation of qtruby. It's caused by the fact that > calling > signals creates a method taking a number of parameters according to the > signature you specified. Calling it again with the same name attempts to > create another method with the same name and (maybe) a different number > of > arguments. Since ruby doesn't allow to have different methods with the > same > name, however, this effectively overwrites the first method. Ok, thanks for the explanation. One last question : In the Qt-Ruby declaration of signals and slots, the C++ keywords "const" and "&" are sometimes added, but they aren't added in the code when a slot is "connected" (only the C++ type is mentioned). For example : ... slots 'a_slot(const QString&)' ... connect an_object, SIGNAL('a_signal(QString)'), self, SLOT('a_slot(QString)') ... Must I add those keywords to the declaration or are they optional? When do I know that I have to add them? Thank you. -- Posted via http://www.ruby-forum.com/.