# QInputDialog syntax

**URL:** <https://www.ruby-forum.com/t/qinputdialog-syntax/96338>\
**Category:** Ruby\
**Created:** [June 28, 2006, 5:48am UTC](https://www.ruby-forum.com/t/qinputdialog-syntax/96338 "2006-06-28T05:48:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsiener](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@gsiener](https://www.ruby-forum.com/u/gsiener)\
**Post date:** [June 28, 2006, 5:48am UTC](https://www.ruby-forum.com/t/qinputdialog-syntax/96338/1 "2006-06-28T05:48:02Z")

</div>

Hi,

I’m new to Ruby and QtRuby. I have used kdevelop to create my first Qt  
based  
program and am struggling with the conversion between the C++ syntax  
used in  
the Qt Reference Document and actual Ruby syntax. In particular  
QInputDialog::getText

I was wondering if someone could provide an example on how to use  
QInputDialog::getText to get a string input and determine whether the  
user  
pressed the ‘Ok’ or ‘Cancel’ button.

Is there any Ruby documentation available for the Qt library?

–  
Regards,

Graham S.

---

<div class="post-metadata">

**Author:** ![gsiener](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@gsiener](https://www.ruby-forum.com/u/gsiener)\
**Post date:** [June 28, 2006, 6:03am UTC](https://www.ruby-forum.com/t/qinputdialog-syntax/96338/2 "2006-06-28T06:03:33Z")

</div>

Graham S. wrote:

> Is there any Ruby documentation available for the Qt library?

I highly recommend

[http://pragmaticprogrammer.com/titles/ctrubyqt/index.html](http://pragmaticprogrammer.com/titles/ctrubyqt/index.html)

–  
M. Edward (Ed) Borasky

> **[世界杯竞猜彩票-世界杯官网竞猜（集团）有限公司](http://www.linuxcapacityplanning.com/)**
>
> 世界杯竞猜彩票一直以来遵守商业道德，世界杯官网竞猜坚持诚信为本，保证诚实经营。世界杯竞猜彩票先后成为安徽省电子商务协会理事单位、安徽省网商协会会员单位、合肥市电子商务协会理事单位、合肥市服务外包行业协会会员单位、安徽省云计算产业促进会会员单位。世界杯官网竞猜一直保持良好的技术及服务态度，更好地为客户服务。

---

<div class="post-metadata">

**Author:** ![gsiener](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@gsiener](https://www.ruby-forum.com/u/gsiener)\
**Post date:** [June 28, 2006, 3:05pm UTC](https://www.ruby-forum.com/t/qinputdialog-syntax/96338/3 "2006-06-28T15:05:57Z")

</div>

Quoting Graham S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Is there any Ruby documentation available for the Qt library?

This is a KInputDialog example, but QInputDialog is the same:

@re = Qt::RegExp.new( “^[\d\w][-,&/\d\s\w]\*”)

brandValidator = Qt::RegExpValidator.new(@re, self)

item = KDE::InputDialog.getText(“New #{@label.downcase}”,   
“Enter new #{@label.downcase}”,   
nil,   
true,   
self,   
“AddItem”,   
brandValidator,   
nil )

I advise to buy Caleb T.’ QtRuby book and “C++ GUI Programming  
with Qt3”. The latter is C++, but you will need it if you want to  
develop anything serious with Qt without getting crazy. You won’t need  
to know a lot of C++ to understand it. Caleb’s book is a good start,  
but you need a lot more.

You can also hang around #qtruby at freenode. Richard Dale and I are  
usually there. Not that I know a lot about Qt, Ruby or QtRuby yet, but  
he is a genius. Really.

---

<div class="post-metadata">

**Author:** ![gsiener](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3ec8ea/32.png) [@gsiener](https://www.ruby-forum.com/u/gsiener)\
**Post date:** [June 28, 2006, 8:13pm UTC](https://www.ruby-forum.com/t/qinputdialog-syntax/96338/4 "2006-06-28T20:13:17Z")

</div>

On Wednesday 28 June 2006 23:02, Pau Garcia i Quiles wrote:

> with Qt3". The latter is C++, but you will need it if you want to  
> develop anything serious with Qt without getting crazy. You won’t need  
> to know a lot of C++ to understand it. Caleb’s book is a good start,  
> but you need a lot more.
> 
> You can also hang around #qtruby at freenode. Richard Dale and I are  
> usually there. Not that I know a lot about Qt, Ruby or QtRuby yet, but  
> he is a genius. Really.

Hi,

Thanks for your code snippet but Richard Dale posted to me directly an  
example  
using Qt::InputDialog which sorted out my problems understanding the  
syntax.

I have already purchased and read the Caleb T.’ QtRuby book. The  
problem I  
ran into was the conversion of C++ syntax to Ruby. I do not really know  
anything about C++ at the moment and it is compounded by the fact I have  
just  
starting to learn Ruby. All my experience is with procedural languages  
such  
as C.

Thank you for the advise about Qt, but the only way I will learn is by  
getting  
in the deep end and learning by my mistakes.

BTW, for the record here is Richards example

ok = Qt::Boolean.new  
text = Qt::InputDialog.getText(  
“MyApp 3000”, “Enter your name:”, Qt::LineEdit::Normal,  
nil, ok, nil )  
if !ok.nil? && !text.empty?  
puts ‘user entered something and pressed OK’  
else  
puts ‘user entered nothing or pressed Cancel’  
end

–  
Regards,

Graham S.
