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.