[Kde-bindings] Help with loading an image from a URL
Pau Garcia i Quiles
pgquiles at elpauer.org
Wed Jun 6 19:47:42 UTC 2007
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to the amount of work, I usually need 10 days to answer)
Quoting Chris Gow <sniffy at rogers.com>:
> On Wednesday 06 June 2007 12:30:42 Pau Garcia i Quiles wrote:
>> Quoting Chris Gow <sniffy at rogers.com>:
>> > Ok its working correctly, but is this the correct way to load an image
>> > from a remote resource or is there an easier way?
>>
>> There is an easier way :-)
> Cool.
>>
>> You can use KIO. It is explained in Larrosa's KDE tutorial which was
>> translated to Ruby and is available at
>> http://developer.kde.org/language-bindings/ruby/kde3tutorial/index.html.
>>
>> lthough chapter 11, which is the one dealing with what you want to do,
>> has not been translated to Ruby yet, it shouldn't be difficult to
>> understand:
>> http://developer.kde.org/~larrosa/visualtutorial/chapter11.html
> I originally looked at the KIO::NetAccess class but dismissed it as
> it creates
> a local file. But given the two options, I guess I'll go with it. Ideally I'd
> like KIO::NetAccess (or something similar) to take a buffer or something. In
> any case, I'm having an issue using the KIO::NetAccess class. I can't seem to
> find the download method locally:
>
> irb(main):001:0> require 'korundum'
> => true
> irb(main):002:0> tmpFile = ""
> => ""
> irb(main):003:0> KIO::NetAccess.download("http://www.google.ca/index.html",
> tmpFile)
> NoMethodError: undefined method `download' for KIO::NetAccess:Class
> from (irb):3:in `method_missing'
> from (irb):3
>
> I'm running Kubuntu Feisty w/KDE 3.5.7. According to adept I am using the
> 3.5.5 bindings.
Two problems here:
1) static bool KIO::NetAccess::download(const KURL&, QString&) is
KDE_DEPRECATED, so Korundum probably does not allow it (I can't verify
because the system I am writing from does not have an usable Korundum
installation)
2) The first argument must be a KURL. Try this:
require 'korundum'
tmpFile = ""
about = KDE::AboutData.new("test", "Testing KIO", "0.1")
KDE::CmdLineArgs.init(ARGV, about)
kapp = KDE::Application.new()
w = Qt::Widget.new(nil, "mywidget")
KIO::NetAccess.download(KDE::URL.new("http://www.google.ca/index.html"),
tmpFile, w)
You need to create a KDE::Application before you use KIO because it
needs a KDE::Instance (at least in KDE 3.x, I think I have read
somewhere the need for KInstance's has been reduced on KDE4 but don't
trust me on that).
As QtRuby and Korundum are implemented via the wonderful
method_missing() method in Ruby, 99% of the time you see a
NoMethodError in QtRuby/Korundum it means the parameters you are
passing are wrong (wrong class, wrong order, etc).
More information about the Kde-bindings
mailing list