Embed QT objects in a Web page

Source: Internet
Author: User
Tags rowcount

According to the most recently read QT advanced programming, QT can be embedded in HTML objects, indeed very powerful. So I wrote a demo, Midway appeared a little problem, JS implementation has a problem, it seems to be submitted to JavaScript, I feel that Python should also improve the appropriate. Here are some important points to make about my mistakes.



1. When adding objects to the HTML, indicate that the id,id of object is used in JavaScript, especially when embedding Qt objects to ensure that you write property names and properties in the QT attribute mechanism.

This makes it very simple to assemble objects, because the properties of QT are dynamically set and can be set directly based on the name of the property, so this can be used on the line, this mechanism

In fact, the script mechanism is the same as QT.

2. The invocation of a property in a script is not the same as a call to a QT public slot function. Property calls do not need to add (), I wrote the script has been executed unsuccessfully because of the rowcount and ColumnCount after the addition of () caused.

3.JS connection to QT signal, connection method: The ID name in JS. Signal name. Connect (JS function)

4. For parsing of object, you can extend the Qwebpage and override

Createplugin (const QString &CLASSID, const qurl &url, const qstringlist &paramnames, const qstringlist &P Aramvalues) interface.

Can look at this part of my Code, as follows:


#include "webpage.h" #include "matrixwidget.h" #include <qtuitools/quiloader>webpage::webpage (Qobject *parent) : Qwebpage (parent) {}webpage::~webpage () {}//Select load Qobject * Webpage::createplugin according to ClassID (const QString &AMP;CLASSID , const Qurl &url, const qstringlist¶mnames, const qstringlist¶mvalues) {Qwidget *widget = NULL; Quiloader uiloader;if (Uiloader.availablewidgets () indexOf (classid)! =-1) {widget = Uiloader.createwidget (ClassID, View ());} else if (ClassID = = "Matrixwidget") {widget = new Matrixwidget (view ());} if (widget) {//getpropertyvalue (paramnames, "height");//paramnames.indexof ("height");// Ensure that the attributes in the paramname and QT attribute mechanisms are consistent to automatically set the data for (int i=0; i<paramnames.size (); ++i) {Widget->setproperty (paramnames[i]. Tolocal8bit (), Qvariant (Paramvalues[i]));}} return widget;} Qvariant webpage::getpropertyvalue (const qstringlist¶mnames, const qstring& PropertyName) {return QVariant ();}


All the code can be downloaded in my resources:

http://download.csdn.net/download/davidsu33/8042983


Embed QT objects in a Web page

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.