Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWebPage setContent -> don't load images
Forum Updated to NodeBB v4.3 + New Features

QWebPage setContent -> don't load images

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Serenity
    wrote on last edited by
    #1

    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 ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Serenity
      wrote on last edited by
      #2

      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 -.-

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved