View Single Post
helex's Avatar
Posts: 543 | Thanked: 802 times | Joined on Apr 2010 @ Germany
#27
Originally Posted by marxian View Post
Are you downloading the image using QNetworkAccessManager, or simply setting the source of a QML Image object? In either case, it shouldn't be too difficult to handle the error if the URI doesn't exist. Let's say you try .bmp first, with QNetworkAccessManager, you can catch the error when the QNetworkReply* emits the finished() signal, i.e
I'm using the QNetworkAccessManager. But in difference to Enigma1 I get the image data as a reply for my request command without extra step.

Code:
http://<IP>/grab?format=jpg
simplified code:
Code:
void appLogic::replyScreenshotFinished(QNetworkReply* r)
{
    if (r->error() == QNetworkReply::NoError) {
        QFile jpg("tmp.jpg")
        jpg.write(r.readAll());
        jpg.close();
    }
    else
    {
        // errorhandling
    }
    disconnect(&manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyScreenshotFinished(QNetworkReply*)));
}
This way you get the screenshot in a file called tmp.jpg. Since I have anyway a command buffer implemented sending several commands in order is no problem for me. So perhaps I could simply try to get both and use the one which is actually a image. But I have still the hope for a more elegant solution.
__________________
I was a Qt Ambassador!

Please DONATE if you like my work!
It's the best way to motivate me to create more stuff for your Device.

Last edited by helex; 2012-02-29 at 02:21.