module Qt
	class Object
		
		def Object.connect2Block(from, signal, &block)
			signalVars = (signal =~ /\((.*)\)/) ? $1 : ""
			Qt::Object.connect(
				from, signal,
				BlockInvocator.new(block, signalVars), SLOT("process(#{signalVars})")
			)
		end
	end

	class BlockInvocator < Qt::Object
		def initialize(block, args)
			super()
			self.class.slots "process(#{args})"
			@toCall = block
		end

		def process(*vars)
			@toCall.call(*vars)
		end
	end
end