# Qtruby problems

**URL:** <https://www.ruby-forum.com/t/qtruby-problems/78903>\
**Category:** Ruby\
**Created:** [December 10, 2006, 11:02am UTC](https://www.ruby-forum.com/t/qtruby-problems/78903 "2006-12-10T11:02:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 10, 2006, 11:02am UTC](https://www.ruby-forum.com/t/qtruby-problems/78903/1 "2006-12-10T11:02:55Z")

</div>

I have both qtruby and qt4-qtruby installed (via the gentoo ebuilds),  
and am trying to run the examples from qt4-qtruby-1.4.7. However, most  
of them are failing with “Unresolved constructor call”. Here’s a  
minimal failure case:

irb(main):001:0\> require ‘Qt’  
=\> true  
irb(main):002:0\> app = Qt::Application.new([])  
=\> #\<Qt::Application:0xb6a24bec name=“irb”\>  
irb(main):003:0\> button = Qt::PushButton.new(“hello world”)  
ArgumentError: unresolved constructor call Qt::PushButton

```
    from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1367:in 

```

`initialize' from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1367:in`call’  
from /usr/lib/ruby/site\_ruby/1.8/Qt/qtruby.rb:1367:in  
`try_initialize' from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1366:in`catch’  
from /usr/lib/ruby/site\_ruby/1.8/Qt/qtruby.rb:1366:in  
`try_initialize' from (irb):3:in`new’  
from (irb):3

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 10, 2006, 2:07pm UTC](https://www.ruby-forum.com/t/qtruby-problems/78903/2 "2006-12-10T14:07:04Z")

</div>

Martin DeMello wrote:

> ArgumentError: unresolved constructor call Qt::PushButton
> 
> ```
> from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1367:in `initialize'
> from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1367:in `call'
> from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1367:in `try_initialize'
> from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1366:in `catch'
> from /usr/lib/ruby/site_ruby/1.8/Qt/qtruby.rb:1366:in `try_initialize'
> from (irb):3:in `new'
> from (irb):3
> 
> ```

It’s because you’re picking up the Qt3 version of QtRuby which doesn’t  
have that constructor. If you install the Qt3 version after the Qt4  
version the default when you do a require ‘Qt’ will be the Qt3 one. If  
you install the Qt4 version of QtRuby after the Qt3 one, then the  
default is Qt4 instead. Maybe use require ‘Qt3’ or require ‘Qt4’ to  
make sure you get the right one.

In the Qt4 version ‘qtruby.rb’ was renamed ‘qtruby4.rb’, and so it is  
easy to see from the trace above what went wrong.

– Richard

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 10, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/qtruby-problems/78903/3 "2006-12-10T14:53:10Z")

</div>

On 12/10/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It’s because you’re picking up the Qt3 version of QtRuby which doesn’t  
> have that constructor. If you install the Qt3 version after the Qt4  
> version the default when you do a require ‘Qt’ will be the Qt3 one. If  
> you install the Qt4 version of QtRuby after the Qt3 one, then the  
> default is Qt4 instead. Maybe use require ‘Qt3’ or require ‘Qt4’ to  
> make sure you get the right one.

Thanks! requiring ‘Qt4’ fixed it. How do I make Qt go back to defaulting  
to Qt4?

martin

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 10, 2006, 3:47pm UTC](https://www.ruby-forum.com/t/qtruby-problems/78903/4 "2006-12-10T15:47:15Z")

</div>

> Thanks! requiring ‘Qt4’ fixed it. How do I make Qt go back to  
> defaulting to Qt4?

I _think_ this is a result of whichever you emerged last. If you  
emerged Qt3 after Qt4, then require ‘Qt’ pulls it in instead.

I recommend just using ‘Qt4’ or ‘Qt3’ explicitly. Also you can check  
via Qt::version to see which one is loaded.

Caleb

---

<div class="post-metadata">

**Author:** ![Martin\_DeMello](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f17d59/32.png) [@Martin\_DeMello](https://www.ruby-forum.com/u/Martin_DeMello)\
**Post date:** [December 10, 2006, 3:51pm UTC](https://www.ruby-forum.com/t/qtruby-problems/78903/5 "2006-12-10T15:51:16Z")

</div>

Martin DeMello wrote:

> On 12/10/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > It’s because you’re picking up the Qt3 version of QtRuby which doesn’t  
> > have that constructor. If you install the Qt3 version after the Qt4  
> > version the default when you do a require ‘Qt’ will be the Qt3 one. If  
> > you install the Qt4 version of QtRuby after the Qt3 one, then the  
> > default is Qt4 instead. Maybe use require ‘Qt3’ or require ‘Qt4’ to  
> > make sure you get the right one.
> 
> Thanks! requiring ‘Qt4’ fixed it. How do I make Qt go back to defaulting to Qt4?  
> Reinstall the Qt4 version of QtRuby so that the Qt.rb file from that  
> release replaces the current one.

– Richard
