• May 02, 2024, 01:03:47 am

Author Topic: Embed QWebView into QDeclarativeItem  (Read 3240 times)

0 Members and 1 Guest are viewing this topic.

Offline yeatse

  • Developer
  • Viewer
  • ****
  • Posts: 8
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : 808
Embed QWebView into QDeclarativeItem
« on: January 07, 2014, 02:17:23 pm »
QML WebView element is a convenient tool for showing a website in qml, but it has some small bugs. They are hard to fix because these bugs come from the backend, called QGraphicsWebView.

To solve this problem, I wrote a class named "QWebViewItem", which embeds QWidget-based QWebView into qml environment. To use this element, include the files in your project, register QWebViewItem in your main.cpp, then use it like this:

WebViewItem {
anchors.fill: parent;
url: "http://www.google.com";
}

You needn't add a Flickable element if the website content is larger than this element. QWebView itself behaviours like a Flickable. So feel free to hack it for your own needs.= =

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Re: Embed QWebView into QDeclarativeItem
« Reply #1 on: January 08, 2014, 11:05:10 pm »
could you tell us about your changes and the new features?

Offline yeatse

  • Developer
  • Viewer
  • ****
  • Posts: 8
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : 808
Re: Embed QWebView into QDeclarativeItem
« Reply #2 on: January 13, 2014, 03:30:01 pm »
If you have used StarBrowser, you will find that when you tap on the blank space at www.google.com, or click a link pointing to an anchor (open html5test.com, then open the corner menu and select one), the content will go "out" of the screen and cannot be back. This is because the page itself doesn't know the position we scroll it to, so some elements will not perform as we expected. But QWebView in Qt C++ doesn't have problems like this.

So my changes:
Use QWebView as the backend instead of QGraphicsWebView

New features:
Fix bugs in QGraphicsWebView

Offline symster

  • Developer
  • Happy Member
  • ****
  • Posts: 214
  • Reputation: 6
  • Symbian Power User
  • Current Phone: : Nokia N8 Soon Nokia 808
Re: Embed QWebView into QDeclarativeItem
« Reply #3 on: January 13, 2014, 03:39:29 pm »
Does it behave the way like webview.Are all the signal and properties is the same with webview?

Offline Allstar12345

  • Allstar Software Founder
  • Administrator
  • Forum Genius
  • ******
  • Posts: 5,235
  • Reputation: 812
    • Allstar Software
  • Current Phone: : OnePlus 8 Pro, Xperia 10, Nexus 6p, Jolla Phone, Nokia N8, Nokia 808 PureView, BlackBerry Z30
Re: Embed QWebView into QDeclarativeItem
« Reply #4 on: January 15, 2014, 05:21:32 pm »
If you have used StarBrowser, you will find that when you tap on the blank space at www.google.com, or click a link pointing to an anchor (open html5test.com, then open the corner menu and select one), the content will go "out" of the screen and cannot be back. This is because the page itself doesn't know the position we scroll it to, so some elements will not perform as we expected. But QWebView in Qt C++ doesn't have problems like this.

So my changes:
Use QWebView as the backend instead of QGraphicsWebView

New features:
Fix bugs in QGraphicsWebView

Only ever does that if you attack the TextField on FP2, seems Qt 4.8.0/4.7.4 has buggier QGraphicWebView's than others.