Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTextBrowser play Epub file but a click of image is not html...



  • If inside html a image is linked .. QTextBrowser ReadOnly click an can not show image... why this?

    If i use setSource(QUrl) its play correct local file & image like a browser at end a screenshot...

    EpubView::EpubView(QWidget *parent) : QTextBrowser(parent) {
      modusNow = 1;
      this->setContextMenuPolicy(Qt::CustomContextMenu);
      ModusPlay();
    }
    void EpubView::ModusPlay() {
      this->setContentsMargins(22, 11, 22, 11);
      this->setReadOnly(true); ////  lesen ..kopieren
      this->setMinimumWidth(400);
      this->setMinimumHeight(400);
      this->resize(600, 500);
      this->setOpenExternalLinks(true);
      this->setOpenLinks(true);
      this->document()->setDocumentMargin(100);
      this->document()->setPageSize(QSizeF(800, 500));
    }
    void EpubView::PlayFile(const QUrl localremote) {
      CCDEBUG() << localremote << " -> open... this ";
      this->OpenEpub(localremote);
    }
    void EpubView::OpenEpub(const QUrl localremote) {
      playepub = new Epub::Converter();
      const QString ebookfile = localremote.toLocalFile();
      CCDEBUG() << ebookfile << " -> !!!!! ebookfile";
      QList<EpubToc> listing = playepub->convert(ebookfile, _ZIPCACHEBOOK_);
      //// list full Table of Contenent toc..   first file cover... 
      CCDEBUG() << listing.size() << " -> size  EpubToc file ... this ";
      if (listing.size() > 0) {
        EpubToc fox = listing.at(0);
        QFileInfo eefile(fox.jumpurl);
        this->setSource(QUrl::fromLocalFile(eefile.absoluteFilePath()));
        ///this->document()->setBaseUrl(QUrl::fromLocalFile(eefile.absolutePath()));
        CCDEBUG() << fox.jumpurl << " -> open first url ... this ";
      }
      ModusPlay();
    }
    
    

    0_1503941813451_qtextbrowser.png


  • Lifetime Qt Champion

    Hi,

    Did you check the link itself ? How does it reference the image ? Where is it located ?



  • The page having one image as src= image + a href=image
    inside page 3 from "A Book about Qt5" as epub format...
    you can test on mac image Hello World..
    the epub is inside as resource to load to test... code..
    https://github.com/pehohlva/QOASIS/blob/master/bin/EpubRead.dmg only search a idea how to make a menu of contenent page toc...

    code is: https://github.com/pehohlva/QOASIS/tree/master/test/dkernel
    any link need a test from QTextBrowser ...



  • Hi i solved this render problem by swap
    QTextBrowser to QWebEngineView now it faster.. but edit is now only via javascript...


Log in to reply