Skip to content

QtWebEngine

Discussions and questions on QtWebEngine
1.3k Topics 3.9k Posts
  • 0 Votes
    11 Posts
    3k Views
    S
    There are two general ways: to use the QtWebKit or the QtWebEngine. There are memory usage and rendering issues with QtWebKit and it is deprecated since Qt 5.5, but its API is synchronous and simplier to use. In case it is possible to use the 5.5 or an older version of Qt with precompiled QWebKit or you are able to build the module for target platform(s) manually (which could be a bit tricky), just try to open target web page in the QWebView (see the demo browser in the examples). If the page is rendered properly, interaction with inputs/buttons is adequate and there are no visible crashes/freezes/memory leaking - you can use the QWebKit :) ... connect( webView->page(), //-- or webView->page()->mainFrame(), depending on the DOM structure SIGNAL(loadFinished(bool), this, SLOT(onWebContentLoaded(bool)); ... void ...::onWebContentLoaded(bool ok) { if(!isLogedIn()) //-- parse HTML to find markers or just check a flag actualized in the doLogIn(); doLogIn(); else extractTheData(); } void ...::doLogIn() { if( QWebFrame *frame = webView->page()->mainFrame() ) { QWebElement inputLogin = frame->findFirstElement( "#user" ); //-- Chrome->View Source (Ctrl+Shift+I)->Copy->Copy Selector QWebElement inputPass = frame->findFirstElement( "#password" ); QWebElement buttonSubmit = frame->findFirstElement( "#login" ); if(!inputLogin.isNull() && !inputPass.isNull() && !buttonSubmit.isNull() ) { inputLogin.setAttribute("value", ui->lineEditLogin->text() ); //-- populate HTML's input via API inputPass.evaluateJavaScript( QString("this.value='%1'").arg( ui->lineEditPass->text())); //-- or via JS buttonSubmit.evaluateJavaScript( "this.click()" ); //-- or you can generate a key/mouse event } } } In case you are forced to use the QWebEngine, things are a bit more complicated: you have to use a QWebChannel to expose your QObject to the JS side, where all interaction/extraction will be done. In both cases to keep alive all routines/events needed for correct page rendering while widget is hidden, set the webView's (or its parent's) attribute Qt::WA_DontShowOnScreen to true.
  • QWebEngineView problems with <select> fields

    Unsolved webengineview select
    2
    0 Votes
    2 Posts
    1k Views
    L
    @l2pd said in QWebEngineView problems with <select> fields: I'm having this problems on a Windows 10 x64 machine. I didn't tried it on linux. Sorry I forgot to mention that I have this problems with version 5.7.0 of Qt.
  • Multiple QWebEngine, keep the same session

    Solved
    2
    0 Votes
    2 Posts
    799 Views
    M
    Solution found use this global variable for all your QWebEnginePage QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
  • Replacement QWebElement?

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    M
    Here is my solution if anyone is interested. I had problem adding the js directly in the html so I used injection QWebEngineProfile *profile = new QWebEngineProfile("MyWebChannelProfile", this); // QWebEngineProfile *profile = qApp->property("WebEngineProfile").value<QWebEngineProfile*>(); QFile webChannelJsFile(":/qtwebchannel/qwebchannel.js"); if( !webChannelJsFile.open(QIODevice::ReadOnly) ) { qDebug() << QString("Couldn't open qwebchannel.js file: %1").arg(webChannelJsFile.errorString()); } else { qDebug() << "OK webEngineProfile"; QByteArray webChannelJs = webChannelJsFile.readAll(); webChannelJs.append( "\n" "var workoutCreator" "\n" "new QWebChannel(qt.webChannelTransport, function(channel) {" " workoutCreator = channel.objects.workoutCreator;" "});" "\n" "function enableSaveButton() {" "var nameValue = $('#name-workout').val();" "var planValue = $('#plan-workout').val();" "var creatorValue = $('#creator-workout').val();" "if (nameValue.length > 0 && creatorValue.length > 0 && planValue.length > 0) {$('#btn-save-workout').prop('disabled', false);}" "else {$('#btn-save-workout').prop('disabled', true);}" "}" ); QWebEngineScript script; script.setSourceCode(webChannelJs); script.setName("qwebchannel.js"); script.setWorldId(QWebEngineScript::MainWorld); script.setInjectionPoint(QWebEngineScript::DocumentCreation); script.setRunsOnSubFrames(false); profile->scripts()->insert(script); } QWebEnginePage *myPage = new QWebEnginePage(profile, ui->webView_createWorkout); ui->webView_createWorkout->setPage(myPage); QWebChannel *channel = new QWebChannel(myPage); ui->webView_createWorkout->page()->setWebChannel(channel); channel->registerObject("workoutCreator", this); } void WorkoutCreator::checkToEnableButtonSave() { if (intervalModel->rowCount() <= 0) { return; } //call JS to activate button! ui->webView_createWorkout->page()->runJavaScript("enableSaveButton();"); }
  • Why I get two <loadFinished> signal sometimes?

    Solved
    6
    0 Votes
    6 Posts
    2k Views
    L
    @QBoy said in Why I get two <loadFinished> signal sometimes?: potential You can runJavaScript after the first <loadFinished> signal emitted. you can construct new QWebChannel in js file when $(document).ready(). js can invoke c++ method when construct the QWebChannel finished. I use Qt5.4(webView)、Qt5.6(webEngineView)、Qt5.7, the js just run once.
  • 0 Votes
    2 Posts
    1k Views
    L
    By the way, chrome run very well on my pc,I open more than 70 page, and it display normal. Just QtWebEngine has this problem.When I open new webengine page, it use too many memory. It troubled me four days, any help will be grateful!
  • "qt is undefined " when I declare QWebChannel

    Unsolved
    4
    1 Votes
    4 Posts
    4k Views
    M
    Let me know if you figured a way to make it work, currently stuck on this too. I must say the documentation is lacking on QWebEngine. The example is too complex for nothing, we don't want a chat server, just a simple WebPage communicating to C++ in both way (printing text and alert message example would be sufficient to understand). I don't understand why they use a QWebSocket since it's not necessary? Any more example around that could help? I did everything the docs says and I can't get it to work js-->c++, the other way is easy with runJavascript
  • Has anyone deployed an application using QtWebEngine on Linux successfully?

    Unsolved
    2
    0 Votes
    2 Posts
    799 Views
    A
    Yes, I have seen that. One problem though is often finding the chromium resources, QtWebEngine will search for them in the Qt prefix paths, so if they are different than QtWebEngine's that can cause issue. QtWebEngine will also try several fallback until it gets to the directory of the executable. Here it is important to note that it is a multi-process architecture, and that besides your own executable also is an executable in libexec, that also needs to find some resources.
  • Qt 5.6: Flash content cannot enter full screen on QWebEngineView

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    A
    It is a known limitation. Pepper Flash for some odd reason use a completely separate fullscreen system than the rest of Blink or Chromium, and it integrates badly with QtWebEngine. If you have control over content, one thing you could probably do, is use HTML5 fullscreen mode to set the embed or object element fullscreen, instead of using the Flash fullscreen.
  • How to send QString to server in Qt 5.6?

    Unsolved qnetworkreply qnetworkrequest qnetworkaccessm network
    7
    0 Votes
    7 Posts
    3k Views
    raven-worxR
    @d1.psy so you want the cookies from the requests you already made with QtWebEngine? If so take a look at QWebEngineCookieStore (see it's signals) and "sync" the cookies into your QNAM.
  • CSS 3D transform: QtWebEngine (Qt 5.5) vs CEF3

    4
    0 Votes
    4 Posts
    2k Views
    A
    See https://bugreports.qt.io/browse/QTBUG-55542
  • Build QTWebEngine from Qt out of devel rpms for centos 6.6

    Unsolved
    1
    0 Votes
    1 Posts
    662 Views
    No one has replied
  • Qt 5.7 Multiply web views and subsystem:console

    Unsolved
    1
    0 Votes
    1 Posts
    501 Views
    No one has replied
  • application exe memory and qtwebengineprocess.exe memory

    Unsolved
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • How to install QtWebEngine

    Unsolved
    10
    0 Votes
    10 Posts
    10k Views
    SGaistS
    I don't remember whether there's a plugin for Designer for QtWebEngine. However it should be pretty easy to set things by hand in the constructor of your object.
  • QtWebEngineProcess.exe immediately crashing on some PCs

    Unsolved crash webenginecore
    3
    0 Votes
    3 Posts
    4k Views
    BerzegerB
    Okay, after four days of research, turns out the specific DLL - Qt5WebEngineCore.dll doesn't like being compressed by UPX. It's not noticeable immediately, but on approx. 10 % of PCs the QtWebEngineProcess simply crashes.
  • Send Mouse Click to WebEngineView

    Solved
    2
    0 Votes
    2 Posts
    2k Views
    T
    You can try the suggested solution here
  • Error while building qtwebengine module from Qt 5.7.0

    Unsolved webengine qt5 qt 5.7
    5
    1 Votes
    5 Posts
    6k Views
    R
    Found the problem. It looks like during the initial stage of nmake, it was spitting out some errors complaining that the command line is too long. I found this ticket and patched those 3 files into my directory and it fixed the problem: https://codereview.qt-project.org/#/c/160622/ Later down the line I experienced another compile issue (https://bugreports.qt.io/browse/QTBUG-54455) and patching this file fixed it: https://codereview.qt-project.org/#/c/163955/
  • 0 Votes
    2 Posts
    2k Views
    SGaistS
    Hi and welcome to devnet, That's a question you should bring to the interest mailing list. You'll find there Qt's developers/maintainers. This forum is more user oriented.
  • How to make qwebengineview support fullscreen?

    Unsolved qt5.7 video fullscree qwebengineview
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied