Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. how to get the real width and hight of the web pages what have loaded?
Forum Updated to NodeBB v4.3 + New Features

how to get the real width and hight of the web pages what have loaded?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
2 Posts 1 Posters 350 Views
  • 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1
    //m_WidgetBrowser means the widget of the webengineview
    connect(m_WidgetBrowser->page(), &QWebEnginePage::loadFinished, [this](bool ok) {
                if (ok) {
                    m_WidgetBrowser->page()->runJavaScript("document.body.scrollWidth", [this](const QVariant &widthResult) {
                        int pageWidth = widthResult.toInt();
                        int viewWidth = m_WidgetBrowser->width();
                        double zoomFactorWidth = static_cast<double>(viewWidth) / static_cast<double>(pageWidth);
                        m_WidgetBrowser->page()->runJavaScript("document.body.scrollHeight;", [this,pageWidth](const QVariant &heightResult) {
                            int pageHeight = heightResult.toInt();
                            int viewHeight = this->m_WidgetBrowser->height();
                            emit onSignalResize(pageWidth,pageHeight);
                            //the signal is to reszie the widget of the webegine m_WidgetBrowser->resize(pageWidth,pageHeight);
    
                        });
                    });
                }
            });
        }
    

    I tested the code above.but on some platforms it worked.some dosent.
    Is there any way to get the real width and height of the pages which loadfinished?

    1 Reply Last reply
    0
    • nicker playerN Offline
      nicker playerN Offline
      nicker player
      wrote on last edited by
      #2

      and if I set the source file whit the setHtml() function.
      it is hard to get the real height and width if the source was made by the txt.

      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