[Kde-bindings] QT TextEdit refresh
Carl Bourne
cbourne at intellect.co.uk
Tue Jul 24 16:16:01 UTC 2007
Hi,
I wonder if you can help. I'm currently exploring rubyqt in conjunction with the latest QT4 libraries. However, I can't seem to get a TextEdit widget to refresh properly. My code runs correctly when I click the button that has a ruby function assigned to it, but the TextEdit field does not update until the ruby function completes.
Here's the code I'm using:-
--------------------------------------------------------------------------------------------------
main.rb
----------
require 'Qt'
require 'dialog.rb'
app = Qt::Application.new(ARGV)
dialog = Dialog.new
dialog.exec
------
dialog.rb
-------
class MyWidget < Qt::Widget
slots 'go()'
def initialize(parent = nil)
super(parent)
setFixedSize(500, 500)
@textedit = Qt::TextEdit.new(self)
@textedit.setGeometry(5, 50, 480, 300)
quit = Qt::PushButton.new(('Generate'), self)
quit.setGeometry(5, 5, 100, 30)
quit.setFont(Qt::Font.new('Arial', 12, Qt::Font::Bold))
connect(quit, SIGNAL(:clicked)) {@textedit.clear(); go() }
end
def go
# @textedit.clear()
@textedit.setText("Generating files:-")
count = 0
50.times do
count+=1
sleep 0.1
@textedit.append("Generating file: "+count.to_s)
puts "hello"
end
@textedit.append("Done")
end
end
app = Qt::Application.new(ARGV)
widget = MyWidget.new()
widget.show()
app.exec()
-------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20070724/de95bc7c/attachment.html>
More information about the Kde-bindings
mailing list