inheritance and Qtruby

G

gnufied

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?
 
R

richard.j.dale

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top