Results 1 to 2 of 2

Thread: QTextDocument Image resource problem

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QTextDocument Image resource problem

    To append Resource on QTextDocument i write on this way:
    doc->addResource( QTextDocument::ImageResource, QUrl(filefullpath), QPixmap(filefullpath) );

    if file exist..

    But on export on other format not HTML i like to export the image as copy to.. on same path from export file.

    and QTextImageFormat isValid done only by image on qrc resource file... inside ..
    all other is display correct image on (QTextBrowser/QGraphicsItem) but QTextImageFormat Pics is false on export, why? i read only the same QTextDocument.

    Qt Code:
    1. /* QTextImageFormat Pics */
    2.  
    3. if (Pics.isValid() && Pics.hasProperty(QTextFormat::ImageName) ) {
    4. /* IMAGE TAG internal external............TAGNR. ENUM 417/418 */
    5. /* SVG convert to png transparent ! / original svg base64 encoded data! xml */
    6. QDomElement inlineimage = createElement("fo:internal-graphic");
    7. const QString hrefadress = Pics.name();
    8. qDebug() << "### image 1 name() " << hrefadress;
    9. /* probe to save on export path */
    10. QFileInfo fimp(hrefadress);
    11. QPixmap lodingimage(hrefadress);
    12.  
    13. if (!lodingimage.isNull()) {
    14. QString path = imagepathexport;
    15. if (!path.endsWith("/")) {
    16. path.append("/");
    17. }
    18. QDir deop(path);
    19. if (!deop.exists()) {
    20. deop.mkpath(path);
    21. }
    22.  
    23. QString ext = fimp.completeSuffix();
    24. ext.toUpper();
    25. QByteArray extension;
    26. extension = ext.toAscii();
    27. QPixmap PicCopy(lodingimage);
    28. const QString filepathgo = path+fimp.fileName();
    29. bool ActionSave = PicCopy.save(filepathgo,extension.data(),100);
    30. qDebug() << "### image 2" << filepathgo << " bool->" << ActionSave;
    31. inlineimage.setAttribute("src",fimp.fileName());
    32. inlineimage.setAttribute("height",QString("%1pt").arg(lodingimage.height()));
    33. inlineimage.setAttribute("width",QString("%1pt").arg(lodingimage.width()));
    34. } else {
    35. /* save only url if not load */
    36. }
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextDocument Image resource problem

    Can you prepare a minimal compilable example reproducing the problem?

Similar Threads

  1. QTextFrame::iterator richtext QTextDocument problem?
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 20th July 2007, 01:02
  2. Replies: 0
    Last Post: 13th July 2007, 22:45
  3. Problem getting an image from a web server
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 12th January 2007, 23:05
  4. problem with the back ground image
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2006, 21:34
  5. problem with image colections
    By zlatko in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2006, 13:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.