[Kde-bindings] Help with loading an image from a URL

Chris Gow sniffy at rogers.com
Wed Jun 6 11:47:57 UTC 2007


Hello:

Not sure if this is exactly the most correct list to post to, but since the 
program I am writing is in Ruby using the kde/ruby bindings I thought I would 
post here.

I'm trying to load an image from a url into a widget but I am getting stuck :
(. I can make a connection to the site and get the data (at least that's what 
appears to be happening) but no data is ever returned. Below is a sample of 
what I am trying to accomplish. There seems to be a lot of overhead so its 
entirely possible that this is not the correct way to do what I want.


#!/usr/bin/ruby
require 'Korundum'

class MyClass < KDE::MainWindow
	slots 'done(bool)'
	def initialize( name )
		super(nil, name) 
		@dataByteArray = Qt::ByteArray.new
		@data = Qt::Buffer.new(@dataByteArray)
		@data.open(Qt::IO_ReadWrite)
		@http = Qt::Http.new(self)
                connect(@http, SIGNAL("done(bool)"), self, SLOT("done(bool)"))
                @http.setHost("www.google.ca")
                @http.get("/intl/en_ca/images/logo.gif", @buffer)

	end

        def done(err) 
		if (!err)
			label = Qt::Label.new("", self)
			label.resize(300, 200)
                        label.setText(@dataByteArray.size.to_s)
			setCentralWidget(label)
			label.show
		end
	end
end

about = KDE::AboutData.new( "p2", "Test", "0.1" )
KDE::CmdLineArgs.init( ARGV, about )
app = KDE::Application.new( )

window = MyClass.new("Test")

app.mainWidget = window
window.resize(300,200)
window.show

app.exec

Currently it will display 0 in the label, I was trying to see if any data was 
being returned before I attempted to display anything.

thanks

-- chris



More information about the Kde-bindings mailing list