# Problem with StringList object in Ruby/Qt4

**URL:** <https://www.ruby-forum.com/t/problem-with-stringlist-object-in-ruby-qt4/126153>\
**Category:** Ruby\
**Created:** [January 15, 2008, 9:10pm UTC](https://www.ruby-forum.com/t/problem-with-stringlist-object-in-ruby-qt4/126153 "2008-01-15T21:10:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rosalind\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Rosalind\_M](https://www.ruby-forum.com/u/Rosalind_M)\
**Post date:** [January 15, 2008, 9:10pm UTC](https://www.ruby-forum.com/t/problem-with-stringlist-object-in-ruby-qt4/126153/1 "2008-01-15T21:10:31Z")

</div>

I’m experimenting with building Ruby applications with Qt4 GUI  
interfaces.

While most of it is going easily - I like using Qt4 more than most GUI  
tools - I seem to have run into a problem with Qt::StringList objects.

I can reduce this to a bare minimum script that produces the exception:

* * *

#!/usr/bin/ruby -wKU

require ‘Qt4’

class ListForm \< Qt::Widget  
def initialize  
super()

```
model = Qt::StringListModel.new()
list = Qt::StringList.new()

```

end  
end

app = Qt::Application.new(ARGV)

test\_form = ListForm.new()  
test\_form.show()

## app.exec()

When I run this, the output is:

## $ ruby slist.rb slist.rb:10:in `const_missing': uninitialized constant Qt::StringList (NameError) from slist.rb:10:in`initialize’ from slist.rb:19:in `new’ from slist.rb:19

I’m sure I’m missing something simple here, I just can’t see what. Any  
thoughts?

Oh yes: Ruby 1.8.6 / Qt 4.3 / Ubuntu 7.10

Rosie

---

<div class="post-metadata">

**Author:** ![Rosalind\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Rosalind\_M](https://www.ruby-forum.com/u/Rosalind_M)\
**Post date:** [January 15, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/problem-with-stringlist-object-in-ruby-qt4/126153/2 "2008-01-15T22:02:18Z")

</div>

Alle martedì 15 gennaio 2008, Rosalind M. ha scritto:

> require ‘Qt4’
> 
> $ ruby slist.rb  
> Oh yes: Ruby 1.8.6 / Qt 4.3 / Ubuntu 7.10
> 
> Rosie

I think this happens because QtRuby uses ruby lists instead of most (if  
not  
all) of the Qt containers. Try doing

list = []

instead of

list = Qt::StringList.new()

Stefano

---

<div class="post-metadata">

**Author:** ![Rosalind\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Rosalind\_M](https://www.ruby-forum.com/u/Rosalind_M)\
**Post date:** [January 16, 2008, 3:13pm UTC](https://www.ruby-forum.com/t/problem-with-stringlist-object-in-ruby-qt4/126153/3 "2008-01-16T15:13:04Z")

</div>

Stefano C. wrote:

> I think this happens because QtRuby uses ruby lists instead of most (if  
> not all) of the Qt containers. Try doing
> 
> list = []
> 
> instead of
> 
> list = Qt::StringList.new()

That seems to be it. Thank you, Srefano!

Rosie
