[Interest] qml <--> c++

jagernicolas at legtux.org jagernicolas at legtux.org
Sun Feb 28 05:15:33 CET 2016


 

Hi,

in my main.qml I have this code :

 WebEngineView {
 id: webview
 url: "192.168.2.1"
 anchors.fill: parent
 onNewViewRequested: {
 var w_ = crecreateObject()
 request.openIn(appWin.w_)
 }
 }

when onNewViewRequested is called, I would like to open the url of the
request in the the same WebEngineView, not creating a new WebEngine. So
I was thinking to create some class who inherits of WebEngine.

I didn't found any class called WebEngine I can inherit, or I did not
found the header... but I found QWebEngine, so I did this :

// in CustomWebView.h
#pragma once
#include <QtWebEngineWidgets/QtWebEngineWidgets>

class CustomWebView : public QWebEngineView
{
 Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY
authorChanged)

public:
 CustomWebView(QWidget *parent);
 CustomWebView();

};

I register the qml inside my main.cpp : 

 qmlRegisterType<CustomWebView>("customWebView", 1, 0, "CustomWebView");

and in my main.qml I did some changes/add :

import CustomWebView 1.0

 CustomWebView {
 id: webview
 url: "192.168.2.1"
 anchors.fill: parent
// onNewViewRequested: {
// var w_ = crecreateObject()
// request.openIn(appWin.w_)
// }
 }

but, when I compiled, I got the msg : Cannot assign to non-existent
property "url"

obviously, I didi some mistake, but where ?

Regards,
Nicolas 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160228/b0a3b1dc/attachment.html>


More information about the Interest mailing list