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

Pau Garcia i Quiles pgquiles at elpauer.org
Wed Jun 6 20:42:30 UTC 2007


Quoting Chris Gow <sniffy at rogers.com>:

> On Wednesday 06 June 2007 15:47:42 Pau Garcia i Quiles wrote:
>> 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)
> I don't think it does as I tried using a KURL too.
>>
>> 2) The first argument must be a KURL. Try this:
> That's what I saw too, but the p3 tutorial on korundum makes   
> reference to this
> class and it uses a string and the KDeveloper tutorial you mentioned
> originally also uses a string (makes reference to the fact that the C++
> compiler will figure out what you mean) so I thought that using a string
> would work. Guess not.

Tutorials might not be up-to-date. The only references you may trust  
are api.kde.org and rbkdeapi/rbqtapi. For instance, look what rbkdeapi  
said for the KIO::NetAccess class:

pgquiles at enigma:~$ rbkdeapi KIO::NetAccess

         [...removed...]
         static bool KIO::NetAccess::download(const KURL&, QString&, QWidget*)
         [...removed...]

Do you notice there is no KIO::NetAccess::download with only two  
arguments? I don't know if the KURL was a problem or not, but trying  
to call the 2-argument KIO::NetAccess::download certainly was. Morale:  
rbkdeapi saves your ass :-)

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to the amount of work, I usually need 10 days to answer)




More information about the Kde-bindings mailing list