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. document()->setMetaInformation does not work

document()->setMetaInformation does not work

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 328 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.
  • P Offline
    P Offline
    Pauly
    wrote on last edited by Pauly
    #1

    In the Qt TextEdit example, there is a load function as below. It does not work as I insert image to the document(??), by doing "cursor.insertImage(imageFormat);", after some searching I added the code of setMetaInformation between the "////" mark (confirmed the setMetaInformation should be executed.). However it still does not work and the image is not displayed. The image will show if opening such html in web browser. What am I missing? Thank you.

    bool TextEdit::load(const QString &f)
    {
    if (!QFile::exists(f))
        return false;
    QFile file(f);
    if (!file.open(QFile::ReadOnly))
        return false;
    
    QByteArray data = file.readAll();
    QTextCodec *codec = Qt::codecForHtml(data);
    QString str = codec->toUnicode(data);
    if (Qt::mightBeRichText(str)) {
        textEdit->setHtml(str);
    } else {
        str = QString::fromLocal8Bit(data);
        textEdit->setPlainText(str);
    }
    //// mypath is the directory to the image file
    #ifdef Q_OS_WIN
        textEdit->document()->setMetaInformation( QTextDocument::DocumentUrl, mypath + "/" );
        qDebug()<<"checked";
    #else
        textEdit->document()->setMetaInformation( QTextDocument::DocumentUrl, "file:" + mypath + "/");
    #endif
    ////
    setCurrentFileName(f);
    return true;
    }
    
    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