[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    rubyQT
From:       Carl Bourne <carl.bourne () intellect ! co ! uk>
Date:       2007-07-24 16:20:54
Message-ID: 57c74feccf2b00c09bbabbfa784f4efa () ruby-forum ! com
[Download RAW message or body]

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()

-------------------------------------------------------------------------------------------------
-- 
Posted via http://www.ruby-forum.com/.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic