jeudi 27 juillet 2017

get HTML from QWebEnginePage in QWebEngineView using Lamda

I want to get the HTML code of a web page opened in QWebEngineView I use toHtml() function in QWebEnginePage Class like this

QWebEnginePage *page = ui->widget->page();
QString HTML = "";
page->toHtml([&HTML](QString html){qDebug() << "code \n\n\n" << html;});

the HTML code of html page appeared in qDebug good without problem the problem here is when I want to use HTML string outside the function when I show the size of the HTML varible it is equal to zero and empty so I tried this

QWebEnginePage *page = ui->widget->page();
QString HTML = "";
page->toHtml([&HTML](QString html){HTML = html;}); // crash
qDebug() << "i want to use HTML here outside the function = " << HTML;

but the app crash show so what should I do so I put the HTML data in the HTML variable so I can use it outside the function
Thanks in advance

Aucun commentaire:

Enregistrer un commentaire