[Qt-interest] In need of help in qtwebkit, QNetworkAccessManager and QNetworkReply
Zaid Amir
z.alamir at genie-soft.com
Wed Feb 24 10:13:41 CET 2010
I have been trying since yesterday to solve this issue but I'm still haven't
moved one step forward... I've been trying to override the QNetworkReply
class but it doesn't seem to function properly. This is the code that I have
reached so far, I have tried many variations but none of them seems to lead
me to the the solution:
First this is the QNetworkReply constructor that I'm using:
CustomReply:: CustomReply (const QUrl& url): QNetworkReply()
{
/*This is only for testing purposes, Manually loading a
local/physical file, And "YES, I KNOW THAT I SHOULD BE CHECKING IF THE
HANDLE IS VALID OR NOT"*/
hFile =
CreateFileA("C:/Users/ZAID-RS7/Pictures/The_Evil_Snowman_by_Beloved_Creature
.jpg", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
connect(this, SIGNAL(QNetworkReply::readyRead()), this,
SLOT(processData()));
//connect(this, SIGNAL(QNetworkReply::commandFinished(int, bool)),
this, SLOT(processRequest(int, bool)));
//emit QNetworkReply::readyRead();
}
As you can see I have tried to emit the readyRead data but it doesn't seem
to work. The processData() function is where I set the IODevice to the read
state and set the content type and length headers, I have even tried to call
the function directly from the constructor and then emit the readyRead and
finished signals but it did not work as well. I have no clue on how to
continue as I feel like I have tried everything. I have found a couple of
examples online that restructures QNetworkReply, but all of those are based
on actual network/online requests that uses QFTP and QHttp classes which I
don't think I need since all files are either local or in resource files as
mentioned in my original question.
Can someone please help, I think I'm lost here.
Regards
-----Original Message-----
From: Markus Goetz [mailto:Markus.Goetz at nokia.com]
Sent: Tuesday, February 23, 2010 4:52 PM
To: ext Zaid Amir
Cc: qt-interest at trolltech.com
Subject: Re: [Qt-interest] In need of help in qtwebkit,
QNetworkAccessManager and QNetworkReply
ext Zaid Amir wrote:
>
>
>
> I have been trying for over a week now to try and load those images
> into memory and return them to my webview to be displayed. I have
> managed to override both QNetworkAccessManager and get the request
> from the currently loading page, parse the given url which is
> basically a special url (for example: "*/rc:image.jpg/*"), this would
> mean that image.jpg is currently residing in a resource file so I
> should search for it and return it to webview to be displayed.
>
>
>
> I am not sure how am I suppose to load the image data into memory and
> point my QNetworkReply object to it. I would appreciate any hint,
> example or idea to make this work.
>
>
>
Override QNetworkAccessManager::createRequest(..)
Make it handle rc: URLs special by returning a ZaidAmirNetworkReply object
In the ZaidAmirNetworkReply class override the readData(..) function to
return data from memory or wherever you have your custom image. Also
make sure to set appropriate Content-Type headers in this reply.
Hope that helps!
Markus
More information about the Qt-interest-old
mailing list