require 'Qt4' class Test < Qt::Widget slots "test()" , "timer_action()" , "process_finished()" def initialize() super @button = Qt::PushButton.new self @timer = Qt::Timer.new @process = Qt::Process.new connect @button , SIGNAL("clicked()") , self , SLOT("test()") connect @timer , SIGNAL("timeout()") , self , SLOT("timer_action()") connect @process , SIGNAL("finished(int, QProcess::ExitStatus)") , self , SLOT("process_finished()") end def test # process & some output # @process.start 'ruby' , ['-e', '1.upto(3){|i| sleep 1; puts i}'] @process.start 'ruby' , ['-e', '3.times{|i| sleep 1; puts i+1}'] , Qt::IODevice::ReadOnly|Qt::IODevice::Unbuffered @timer.start 1001 end def timer_action puts 'timer' # @process.waitForReadyRead 0 txt = @process.readAll # the problem: readAll doesn't pickup the output until the process finished, is there a way to get the output while the process is still running? unless txt.empty? puts 'live' , txt # doesn't get here end end def process_finished puts "process_finished" # puts 'dead' , @process.readAll @timer.stop end end app = Qt::Application.new ARGV t = Test.new t.show app.exec