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 ¶mnames, 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 &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