Interaction architecture of html and qt hybrid ui

Source: Internet
Author: User

Qwebkit builds a communication bridge between c ++ and html, decoupling the underlying development of software from the Development of ui, as long as the underlying api is stable and powerful enough, that makes it easy to develop the ui even if it is changeable. (For qt c ++ developers, you don't need to compile it... ^ _ ^). You can update the ui in real time, or remove the old version (change the server's html), or add js statistics .. among others, the reason why the World Wide Web is interesting is that many providers have super powerful control and content delivery capabilities. the traditional native application is often difficult to distribute to users after update, and even users do not accept updates .... hybrid applications not only solve the code confidentiality issue, but also solve the content delivery issue. For example, if the software synchronously develops functions and displays, as long as the functions are completed quickly, once the api is specified, the product can immediately go online to seize the market, because the ui can be updated at any time and then distributed to your applications.


First, we need to understand how qt interacts with html. First, we should start from Master to slave.

Our design principle is that the underlying open enough stable and powerful api, the ui Layer calls or combines these APIs for job. OK, the main is the ui. From the bottom layer, we will first determine a certain method for requesting the underlying services of html pages (in fact, it is the metadata system provided by qt, but we make it more fun)

We add a custom field to the html meta.



Require_core is the added meta field, which indicates the Class Name of the requested api (this class must be a subclass of QObject at the underlying layer, and the constructor is Q_INVOKABLE. Open APIs are slots)

Let's take a look at CAdbReactor.



Pay attention to the red line. This is a macro. Let's take a look. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20140310/20140310091813220.jpg" alt = "\">


Well... F_DEC_REFLECT and F_USE_REFLECT. What do you think? Yes, reflection creates an object.


My thoughts are scattered. It's okay. Let's look at things.








OK. Let's try to think about these things together:

An html require_core Field

One WizardHTMLEE

One reflection

We connected the completed page loading signal to the PageLoadFinished slot of WizardHTMLEE, asked WizardHTMLEE to parse the require_core field, and then used reflection to create the corresponding api service object, you can call these APIs on the html page. Of course, you need to wait until the api service object is created.


Html and qml reflection engines). Of course, if you can understand this article, I think these are just physical skills.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.