QWebPage setContent -> don't load images



  • Hello,

    I have a problem with the function "setContent".
    I want to create a HTML page from different html files:
    @
    if(listnews.isEmpty()) {
    htmlcontent.append("No news available!");
    } else {
    for(int i=0;i<listnews.count();i++) {
    QFile file(newslocation+listnews.at(i));
    file.open(QIODevice::ReadOnly);
    htmlcontent.append(file.readAll());
    file.close();
    htmlcontent.append("<br><hr><br>");
    }
    }@

    listnews is a QStringList with html-filenames in a folder newslocation on my harddrive.
    The html files has a refence to an image located in the directory newslocation as the html files.

    When I use now something like
    @webpage->mainFrame()->setContent(htmlcontent,QString(),QUrl(newslocation));@

    I can see the text content without the images file.

    With @ QFile file(newslocation+"index.html");
    if(file.exists()) file.remove();
    file.open(QIODevice::WriteOnly);
    file.write(htmlcontent);
    file.close();
    webpage->mainFrame()->setUrl(QUrl(newslocation+"index.html"));@

    I can see the images, but I have the problem, that I have to write a index.html file, what I don't like to do.
    Is there a way to load the Content through the setContent function with loading the images in the folder newslocation ?



  • Also before opening the file "index.html"
    @
    qDebug() << "File remove" << QFile::remove(newslocation+"index.html");@

    Doesn't work.
    So it append all the time the last content -.-


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.