M
Matthew Borgeson
Guten Tag, everyone-
I have finally found the time to sit down and attempt GUI programming
with QtRuby. I am attempting to use QtRuby from within KDevelop to make
a simple widget in Qt Designer, run the .ui file through rbuic, and then
simply modify the connections.
The widget in question has 3 lineEdit fields, all three of which begin
blank. Ultimately, I want eventually to have the lineEdit3 field
(labeled "sum") to "automagically" populate with the sum of the first
two lineEdit fields once the user had entered non-zero numbers.
My current goal is to simply have the lineEdit3 field "automagically"
display the word "fudge" whenever a number is simply entered into
lineEdit1, I have looked at the Rapid GUI Development Fridays book, The
Ruby Way, and various online tutorials to help me with this to no avail.
Here is the code so far:
# Form implementation generated from reading ui file 'sum.ui'
#
# Created: Mon Aug 3 16:38:58 2009
# by: The QtRuby User Interface Compiler (rbuic)
#
# WARNING! All changes made in this file will be lost!
require 'Qt'
class Form1 < Qt::Widget
slots
attr_reader :textLabel1
attr_reader :textLabel2
attr_reader :textLabel3
attr_reader ushButton1
attr_reader :lineEdit1
attr_reader :lineEdit2
attr_reader :lineEdit3
#start my slots
'update(const QString &)'
#end my slots
def initialize(parent = nil, name = nil, fl = 0)
super
if name.nil?
setName("Form1")
end
#start my variables
#end my variables
@textLabel1 = Qt::Label.new(self, "textLabel1")
@textLabel1.setGeometry( Qt::Rect.new(160, 50, 111, 31) )
@textLabel2 = Qt::Label.new(self, "textLabel2")
@textLabel2.setGeometry( Qt::Rect.new(160, 90, 121, 31) )
@textLabel3 = Qt::Label.new(self, "textLabel3")
@textLabel3.setGeometry( Qt::Rect.new(150, 140, 121, 31) )
@pushButton1 = Qt:ushButton.new(self, "pushButton1")
@pushButton1.setGeometry( Qt::Rect.new(270, 50, 71, 31) )
@lineEdit1 = Qt::LineEdit.new(self, "lineEdit1")
@lineEdit1.setGeometry( Qt::Rect.new(30, 50, 90, 31) )
@lineEdit2 = Qt::LineEdit.new(self, "lineEdit2")
@lineEdit2.setGeometry( Qt::Rect.new(30, 90, 90, 31) )
@lineEdit3 = Qt::LineEdit.new(self, "lineEdit3")
@lineEdit3.setGeometry( Qt::Rect.new(30, 140, 90, 31) )
#start my connections
Qt::Object.connect(@lineEdit1, SIGNAL("textChanged(const QString &)"),
@lineEdit3, SLOT('update(const QString &)') )
Qt::Object.connect(@pushButton1, SIGNAL("clicked()"), @lineEdit1,
SLOT("clear()") )
Qt::Object.connect(@pushButton1, SIGNAL("clicked()"), @lineEdit2,
SLOT("clear()") )
Qt::Object.connect(@pushButton1, SIGNAL("clicked()"), @lineEdit3,
SLOT("clear()") )
#end my connections
languageChange()
resize( Qt::Size.new(581, 480).expandedTo(minimumSizeHint()) )
clearWState( WState_Polished )
end
#start my slot methods
def update
@lineEdit3.setText( trUtf8("fudge"))
end
#end my slot methods
#
# Sets the strings of the subwidgets using the current
# language.
#
def languageChange()
setCaption(trUtf8("Form1"))
@textLabel1.setText( trUtf8("addend 1") )
@textLabel2.setText( trUtf8("addend 2") )
@textLabel3.setText( trUtf8("sum") )
@pushButton1.setText( trUtf8("Reset") )
end
protected :languageChange
end
Here is the error message I get when I try to run it:
ruby -KA -C"/home/hujraad/Desktop/sum" -I"/home/hujraad/Desktop/sum/."
"sum.rb"
QObject::connect: No such slot Qt::LineEdit::update(const QString&)
QObject::connect: (sender name: 'lineEdit1')
QObject::connect: (receiver name: 'lineEdit3')
*** Exited normally ***
I believe I have the connections in correctly, as I have already
practiced that with other connections. Have I improperly syntaxed the
update() method?
any help is appreciated; thanks in advance
Matthew Borgeson
I have finally found the time to sit down and attempt GUI programming
with QtRuby. I am attempting to use QtRuby from within KDevelop to make
a simple widget in Qt Designer, run the .ui file through rbuic, and then
simply modify the connections.
The widget in question has 3 lineEdit fields, all three of which begin
blank. Ultimately, I want eventually to have the lineEdit3 field
(labeled "sum") to "automagically" populate with the sum of the first
two lineEdit fields once the user had entered non-zero numbers.
My current goal is to simply have the lineEdit3 field "automagically"
display the word "fudge" whenever a number is simply entered into
lineEdit1, I have looked at the Rapid GUI Development Fridays book, The
Ruby Way, and various online tutorials to help me with this to no avail.
Here is the code so far:
# Form implementation generated from reading ui file 'sum.ui'
#
# Created: Mon Aug 3 16:38:58 2009
# by: The QtRuby User Interface Compiler (rbuic)
#
# WARNING! All changes made in this file will be lost!
require 'Qt'
class Form1 < Qt::Widget
slots
attr_reader :textLabel1
attr_reader :textLabel2
attr_reader :textLabel3
attr_reader ushButton1
attr_reader :lineEdit1
attr_reader :lineEdit2
attr_reader :lineEdit3
#start my slots
'update(const QString &)'
#end my slots
def initialize(parent = nil, name = nil, fl = 0)
super
if name.nil?
setName("Form1")
end
#start my variables
#end my variables
@textLabel1 = Qt::Label.new(self, "textLabel1")
@textLabel1.setGeometry( Qt::Rect.new(160, 50, 111, 31) )
@textLabel2 = Qt::Label.new(self, "textLabel2")
@textLabel2.setGeometry( Qt::Rect.new(160, 90, 121, 31) )
@textLabel3 = Qt::Label.new(self, "textLabel3")
@textLabel3.setGeometry( Qt::Rect.new(150, 140, 121, 31) )
@pushButton1 = Qt:ushButton.new(self, "pushButton1")
@pushButton1.setGeometry( Qt::Rect.new(270, 50, 71, 31) )
@lineEdit1 = Qt::LineEdit.new(self, "lineEdit1")
@lineEdit1.setGeometry( Qt::Rect.new(30, 50, 90, 31) )
@lineEdit2 = Qt::LineEdit.new(self, "lineEdit2")
@lineEdit2.setGeometry( Qt::Rect.new(30, 90, 90, 31) )
@lineEdit3 = Qt::LineEdit.new(self, "lineEdit3")
@lineEdit3.setGeometry( Qt::Rect.new(30, 140, 90, 31) )
#start my connections
Qt::Object.connect(@lineEdit1, SIGNAL("textChanged(const QString &)"),
@lineEdit3, SLOT('update(const QString &)') )
Qt::Object.connect(@pushButton1, SIGNAL("clicked()"), @lineEdit1,
SLOT("clear()") )
Qt::Object.connect(@pushButton1, SIGNAL("clicked()"), @lineEdit2,
SLOT("clear()") )
Qt::Object.connect(@pushButton1, SIGNAL("clicked()"), @lineEdit3,
SLOT("clear()") )
#end my connections
languageChange()
resize( Qt::Size.new(581, 480).expandedTo(minimumSizeHint()) )
clearWState( WState_Polished )
end
#start my slot methods
def update
@lineEdit3.setText( trUtf8("fudge"))
end
#end my slot methods
#
# Sets the strings of the subwidgets using the current
# language.
#
def languageChange()
setCaption(trUtf8("Form1"))
@textLabel1.setText( trUtf8("addend 1") )
@textLabel2.setText( trUtf8("addend 2") )
@textLabel3.setText( trUtf8("sum") )
@pushButton1.setText( trUtf8("Reset") )
end
protected :languageChange
end
Here is the error message I get when I try to run it:
ruby -KA -C"/home/hujraad/Desktop/sum" -I"/home/hujraad/Desktop/sum/."
"sum.rb"
QObject::connect: No such slot Qt::LineEdit::update(const QString&)
QObject::connect: (sender name: 'lineEdit1')
QObject::connect: (receiver name: 'lineEdit3')
*** Exited normally ***
I believe I have the connections in correctly, as I have already
practiced that with other connections. Have I improperly syntaxed the
update() method?
any help is appreciated; thanks in advance
Matthew Borgeson