View Full Version : how to transfer javascript string array to qt with qtwebkit
kraft
19th August 2010, 09:12
var ar = new Array("one", "two");
plugin.do(ar);
qt object
class plugin:QObject{
Q_OBJECT
public Q_SLOTS:
void do();
};
how to define function "do()" ?
Thanks
hvitual
19th August 2010, 11:34
class Plugin : QObject {
Q_OBJECT
public slots:
void do(const QVariantList ¶ms); // in your instance, you use QStringList instead of QVariantList
}
Read more:
http://doc.qt.nokia.com/4.6/scripting.html#conversion-between-qtscript-and-c-types
mihaiadrian
15th March 2011, 14:19
Thank you. With QStringList it works
aLukas
21st October 2012, 12:31
Hi.
I try to do as you
class AxBouncer : public QWidget, public QAxBindable
{
Q_OBJECT
public slots:
...
void setXxx(const QStringList& list);
signals:
void bouncing();
}
...
void AxBouncer::setXxx(const QStringList& list) // or QVariantList
{
emit bouncing();
QMessageBox::information( this, "About QSimpleAX", "This is a Qt widget, and this slot has been\n"
"called through ActiveX/OLE automation!" );
emit bouncing();
}
javascript:
var ar = new Array("123","456","789");
AxBouncer.setXxx(ar[2]);
it works.
This code
AxBouncer.setXxx(ar);
Throws the error:
QMetaType::registerTypedef: Binary compatibility break
Type name 'QStringList' previously registered as typedef of 'QStringList'[11],
now registering as typedef of 'IDispatch*'[1028]
bouncing signal does not work at all.
function AxBouncer::bouncing()
{
document.title = "Bouncing again!";
alert("Bouncing again!");
}
window 7, internet explorer 9, Qt 4.8.x and qt-everywhere-opensource-src-5.0.0-beta1, Microsoft Visual Studio 2008 and 2010 + SP1
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.