[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

inheritance and Qtruby

hemant

4/25/2006 9:20:00 PM

I have been hacking around with qtruby and was curious to see, how
designer Forms are rendered in qtruby.

So, here is my question, except writting writable attributes, is there
anyway..that i can make instance variables available to derived classes
also?

For example: lets say i have created a Form using designer and i have
added a listbox to it...and now to
populate that listbox..i need to put some code in my derived
class...where i will be actually populating it.

Now..as i see...there can be two approaches to solve this problem...one
is just create mainform.ui.rb and redefine that class and write the
code to populate the listbox.

The other is...to in designer make the listbox as a public or protected
variable so that rbuic after code generation...generates writable
attributes for it..and in the derived class write the code..to populate
the listbox....

i am sort of unhappy with both the approaches....is there any other way?

1 Answer

richard.j.dale@gmail.com

4/26/2006 9:46:00 AM

0

But instance variables can be accessed by derived classes, for
instance:

class Foo
def initialize
@foo = "hello there"
end
end

class Bar < Foo
def greet
puts @foo
end
end

b = Bar.new
b.greet

The greet call will print 'hello there', as class Bar can access the
@foo instance variable in its super class Foo.

Maybe you can post a specific code sample if I haven't understood your
problem correctly? In the Qt3 version of the rbuic generated code, you
can either subclass to customise, or you can just redefine methods in
the same class as the one generated by rbuic to customise.