QInputDialog syntax

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.

Graham S. wrote:

Is there any Ruby documentation available for the Qt library?

I highly recommend

http://pragmaticprogrammer.com/titles/ctrubyqt/index.html


M. Edward (Ed) Borasky

Quoting Graham S. [email protected]:

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.

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.