Forum: Ruby Re: Qt4 not supported?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Olivier L. (Guest)
on 2009-05-20 21:41
(Received via mailing list)
hello,

thank you for your answer, ken.
I still have an error : here is my program :

    require ('Qt')

    class Fen_princ < Qt::MainWindow

        def initialize
            zone_centrale=Qt::Widget.new
            nom=Qt::LineEdit.new
            layout=Qt::FormLayout.new
            layout.addRow("Votre nom :",nom)
            zone_centrale.setLayout(layout)
            setCentralWidget(zone_centrale)
    <---- line 11

        end

    end



    app=Qt::Application.new(ARGV)
    fenetre=Fen_princ.new()                                       <-----
    line 19
    fenetre.show
    app.exec


and here is the error :

    C:/Users/lolveley/Documents/Visual Studio
    2008/Projects/test_qt_central_widget/test_qt_central_widget/rubyfile.rb:11:in
    `method_missing': Instance is not initialized, cannot call
    setCentralWidget (ArgumentError)
        from C:/Users/lolveley/Documents/Visual Studio
    2008/Projects/test_qt_central_widget/test_qt_central_widget/rubyfile.rb:11:in
    `initialize'
        from
    c:/ruby/lib/ruby/gems/1.8/gems/qtruby4-1.4.10-mswin32/lib/Qt/qtruby4.rb:2398:in
    `call'
        from
    c:/ruby/lib/ruby/gems/1.8/gems/qtruby4-1.4.10-mswin32/lib/Qt/qtruby4.rb:2398:in
    `try_initialize'
        from
    c:/ruby/lib/ruby/gems/1.8/gems/qtruby4-1.4.10-mswin32/lib/Qt/qtruby4.rb:2397:in
    `catch'
        from
    c:/ruby/lib/ruby/gems/1.8/gems/qtruby4-1.4.10-mswin32/lib/Qt/qtruby4.rb:2397:in
    `try_initialize'
        from C:/Users/lolveley/Documents/Visual Studio
    2008/Projects/test_qt_central_widget/test_qt_central_widget/rubyfile.rb:19:in
    `new'
        from C:/Users/lolveley/Documents/Visual Studio
    2008/Projects/test_qt_central_widget/test_qt_central_widget/rubyfile.rb:19

can you help me?

lolveley.








___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son
interface révolutionnaire.
http://fr.mail.yahoo.com
Stefano C. (Guest)
on 2009-05-20 21:59
(Received via mailing list)
On Wednesday 20 May 2009, lolveley wrote:
> |            zone_centrale=Qt::Widget.new
> |
> |
> |    C:/Users/lolveley/Documents/Visual Studio
> |
> | 2008/Projects/test_qt_central_widget/test_qt_central_widget/rubyfile.rb:1
> |1:in `method_missing': Instance is not initialized, cannot call

You forgot to call the superclass's initialize method. Usually, when
subclassing Qt::Object or Qt::Widget, it's better to put a call to super
as
first line of the initialize method (it's not required, as long as you
don't
call any method of the base class before doing so, but it helps avoiding
to
forget it).

I hope this helps

Stefano
Olivier L. (Guest)
on 2009-05-21 02:38
(Received via mailing list)
Stefano C. a écrit :
>> |
>> |
>> |
> first line of the initialize method (it's not required, as long as you don't
> call any method of the base class before doing so, but it helps avoiding to
> forget it).
>
> I hope this helps
>
> Stefano
>
>
>
thank you stefano, it is ok now.

olivier.





___________________________________________________________________________
Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son
interface révolutionnaire.
http://fr.mail.yahoo.com
This topic is locked and can not be replied to.