Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.6.0
-
None
-
Windows 7, 64-bit, Service Pack 1
Description
UPDATE
I realized I was using "boolean" which is typedef'd to:
typedef unsigned char boolean;
So this report actually concerns an unsigned char. Still an issue, but a minor one.
---------------
If I create a QWebChannel with these signals (used to send information from C++ to JavaScript):
signals: void doMyTest(const QString &testString, boolean testBool); void doMyTestInt(const QString &testString, int testInt);
and I call them like so:
emit doMyTest( QString("Raging Inverno was here."), true); // TESTING!!! emit doMyTestInt( QString("Testing integer: "), 57); // TESTING!!! emit doMyTestInt( QString("Testing integer: "), 0); // TESTING!!! emit doMyTestInt( QString("Testing integer: "), 1); // TESTING!!!
and I put in JavaScript code to receive like this:
if ( window.qt && window.qt.webChannelTransport ) { new QWebChannel( window.qt.webChannelTransport, function(channel) { // make dialog object accessible globally window.webChannelDialog = channel.objects.dialog; window.webChannelDialog.doMyTest.connect( function(theString, theBoolean) { Utils.log("THIS IS A TEST! Parameters passed in: ", theString, theBoolean); }); window.webChannelDialog.doMyTestInt.connect( function(theString, theInt) { Utils.log("TESTING integer: ", theString, theInt); }); }); });
then the output is:
THIS IS A TEST! Parameters passed in: Raging Inverno was here. null
TESTING integer: Testing integer: 57
TESTING integer: Testing integer: 0
TESTING integer: Testing integer: 1
The boolean is always null, but passing an integer (including a 0 or 1 value) works.
Workaround: use integer, not boolean type.
I checked the docs, and see no indication that boolean is not supported:
http://doc.qt.io/qt-5/qwebchannel.html