Remove the mapping between the property 'QObject::objectName' and 'name'
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Hi Florian,
Is there any reason why the property 'QObject::objectName' is mapped to the property 'name'? I guess it was related to keep compatibility with Qt 3.x (where property objectName was name). Could it be possible to remove this compatibility (or add a macro to enable/disable it)?
The mapping can be found in the file src/PythonQtClassInfo.cpp (lines 137-144).
Thanks,
Arnaud
Yes, that is a legacy Qt3 feature because MeVisLab used Qt3 and PythonQt has Qt3 origins... I can make it a PythonQt::init() feature, will put it on my TODO list.
Thanks a lot.
This has been fixed on the svn trunk, use PYTHONQT_SUPPORT_NAME_PROPERTY define to get
the name -> objectName alias behaviour, default is off.
The unit test "PythonQtTestApi::testProperties()" should be adapted too.
void PythonQtTestApi::testProperties()
{
PythonQtObjectPtr main = PythonQt::self()->getMainModule();
+#ifdef PYTHONQT_SUPPORT_NAME_PROPERTY
// check for name alias (for backward comp to Qt3)
main.evalScript("obj.name = 'hello'");
QVERIFY(QString("hello") == main.getVariable("obj.name").toString());
+#endif
main.evalScript("obj.objectName = 'hello2'");
QVERIFY(QString("hello2") == main.getVariable("obj.objectName").toString());
Last edit: Arnaud Barré 2015-06-04