From: Arturo Bonechi Date: 2010-11-21T21:20:37+09:00 Subject: Re: Qt-Ruby implementation of the "Address Book Example" Thank you for the reply! Stefano Crocco wrote in post #962907: > I'm not completely sure, but this should work: > - define a method called add_entry which takes two optional arguments > having > nil as default value. Inside the method, you check whether one of the > arguments is nil or not and choose the correct behaviour accordingly: > > def add_entry name = nil, address = nil > if name and address > #behave as the addEntry(QString, QString) function > else > #behave as the addEntry() function > end > end Indeed, it works! The simplest solution is often the better! Thank you! > - define two slots, one with no arguments and one with two arguments: > > slots 'add_entry()', 'add_entry(QString,QString)' By the way, I have some questions again. - In this example, they use the QPair class. It seems that this class isn't implemented in Qt-Ruby (as for the array and hash classes). So I use an array of size two instead and it seems to work fine. Is it the way to do it or do I have to use an other Ruby class to use QPair? - If I want to create a slot that have a Ruby hash as parameter, which QT class must I use in the slot declaration (QHash, QMap, ...)? > Note that this won't work with signals: there can be only one signal > with a > given name, regardless of its signature. I didn't knew that, thank you. Is it specific to Qt-Ruby or it is the same in C++? > I hope this helps > > Stefano Yes it helps, thanks again! -- Posted via http://www.ruby-forum.com/.