1 Attachment(s)
WebView with QQuickWidget and QQuikView
Hi,
I am trying to view an html file(google maps) with WebView on QQuickWidget. The html loads without an error(console log says that) ;but nothing is shown on QQuickWidget, just a white screen..
When I replace QQuickWidget with QQuickView everything works fine. But since there are some issues with QQuickView on mobile platforms, I dont want to use it.
I have attached a minimal runnable code.
Any idea?
Thanks in advance..
Code looks like that:
Code:
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
#ifdef WITH_QUICKWIDGET
view = new QQuickWidget();
ui->verticalLayout->addWidget(view);
#else
view = new QQuickView();
ui->verticalLayout->addWidget(container);
#endif
mapApiKey
= QString::fromLatin1("AIzaSyAOeIxkqfAs9HQrz_PY7QPz7ZzKiML7hDE");
loadHtml();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::loadHtml()
{
QString htmlData
= loadFileData
(QString::fromLatin1(":/web/map.html"));
htmlData.
replace(QLatin1String("$$WEB_DIR"),
QUrl::fromLocalFile(m_webDir
).
toString());
m_filePath = saveFile( htmlData, htmlfname);
QObject *object
= view
->rootObject
();
QQmlProperty
::write(object,
QString::fromLatin1("url"),
QUrl::fromLocalFile(m_filePath
).
toString());
}
{
data = txt.readAll();
readfile.close();
}
return data;
}
{
txt << htmldata;
writefile.close();
}
return mpath;
}
Re: WebView with QQuickWidget and QQuikView
I have detected a problem. In the weblink.qml, when I replace :
Code:
WebView {
id: webView
anchors.fill: parent
with:
Code:
WebView {
id: webView
width : 1920
height: 1080
The web page shows up on QQuickWidget correctly. But of course size of the webview is not changing dynamically in that case. So it looks like "anchors.fill: parent" is not working as expected with WebView and QQuickWidget combination.
Is this a known bug and is there any workaround for this ? Thanks