On 11 Jan, Jens Luedicke wrote:
> Hi there ...
> 
> In Perl there is the @_ array that contains all the
> data that is passed to a function. 

Normally there is no such thing in Ruby, AFAIK. You get all parameters
passed to the arguments you mentioned in the parameterlist during method
definition. So if Ruby detects you passing too much or too less
parameters to a method it will complain!

You can tell ruby that a method may contain unlimited arguments like
this:

  def meth1(*rest_of_args); p rest_of_args end
  def meth2(a, *any_more); p a, any_more end

Method meth1 can take zero to n arguments that all are passed as list to
'rest_of_args'. Method meth2, however, can take 1 to n arguments. The
first will be passed to 'a', the rest as list to 'any_more'.

> I want to check what data (if any) is passed
> to a function if I click on a QPushButton...
> 
> @button = QPushButton.new("Nedit", @vbox)
> @button.resize(100, 30)
> Qt2::connect(@button,QSIGNAL('clicked()'),self, 'button_clicked')
> @button.show

Hmmm ... I do not know the QT binding for Ruby very well, but the
Qt2::connect syntax suggests that the signal 'clicked()' with *no*
argument will be connected to the slot/method 'button_clicked' that
therefore do not *take* or even *expect* any argument.

AFAIK, right now, QPushButton will only sent a 'clicked()' signal
without arguments (no docu handy right now).

So you cannot pass callback data here, I guess. What you perhaps could
do is catch the signal and 'emit' another one with arguments to the
'button_clicked' method afterwards.

> button_clicked would handle the callback if the button is
> clicked. My problem is that I don't know how to pass other
> data to the callback and so a little more knowledge
> about Ruby's @_ would be helpful... 

As I tried to show there is no way of passing data here except catching
and emitting of another one. I do not know the right QT term for that,
but it should be something like Signal Forwarding or such. 


Sorry,
\cle