Menu

Support for Qt 5?

2012-09-25
2015-01-14
1 2 > >> (Page 1 of 2)
  • Chris Meyer

    Chris Meyer - 2012-09-25

    Now that Qt 5 is in beta stage, I'm wondering if PythonQt will provide a compatible version?

     
  • Florian Link

    Florian Link - 2012-09-25

    This might take some time, since we are currently not planning to switch MeVisLab to Qt 5. I will only do this effort when MeVisLab switches to Qt 5. But maybe someone else will jump in?

     
  • Florian Link

    Florian Link - 2012-12-07

    Porting to Qt5 has two aspects:

    1) Getting the core PythonQt to build (that should be merely adjusting the qmake profile and maybe some incompatibilities in QMetaObject and friends)
    2) Getting the Qt 4 wrappers to work (run the pythonqt_generator and see what happens… Some extra includes and fixes in the typesystem might be required)

    The Qt wrappers could be done in two ways: Qt4 backward compatible (With widgets being located in PythonQt.QtGui) or Qt5 only (with widgets being located in a new PythonQt.QtWidgets package).

    I would also think it might be useful to watch what PySide and PyQt are doing in that respect (google for "PySide Qt5" or "PyQt Qt5").

    So if you only require the core PythonQt library (without complete Qt wrappers), it should be the work of 1-2 days and you can contribute the code to PythonQt. If you aim for the complete wrappers, using Qt4 wrappers is the easiest but will take some tweaking to adapt. Generating real Qt5 wrappers is more work.

    regards,
    Florian

     
  • Melven Röhrig-Zöllner

    Thanks for the fast answer.

    I'll probably have a look at the core PythonQt when QT5 gets released.
    Currently we're also linking the QtAll-wrappers, but we may not really need them right now (though they should be useful to us later…).

    When I am successfull, I'll let you know!

    By the way, PyQt seems to have some basic QT5 support: see http://www.riverbankcomputing.co.uk/news/pyqt-495

    Regards,
    Melven

     
  • Melven Röhrig-Zöllner

    So I tried it and got it to run quite well already; in different versions…

    As assumed I needed to change some stuff in the PythonQt-code (especially QMetaMethod::signature has been renamed to QMetaMethod::methodSignature).
    I put some ifdefs around, so the modified code works for both versions (4 and 5) of qt.

    Additionally some api changes in Qt5 prevented the builtin qt-core and qt-gui to compile, there I just removed some (probably not so important) functions.

    I didn't try to get to run the QtAll-extension with the Qt4.6.2 API.

    But there is already a version of the qtscriptgenerator that worked together with qt5 for me (with some small changes):
    https://github.com/svalaskevicius/qtscriptgenerator

    And after some fancy git-merging I persuaded the qtscriptgenerator to produce pythonqt-"script" code for qt5.
    (I first merged the changes from the generator directory in an older version of the qtscriptgenerator, than updated to the newest version for qt 5.0 and needed to resolve some conflicts afterwards…)

    As a result of my work, most of the examples seem to run fine (at least they start); though some of the tests fail:

    .../tests$ LD_LIBRARY_PATH=../lib/ ./PythonQtTest
    ********* Start testing of PythonQtTestApi *********
    Config: Using QTest library 5.0.0, Qt 5.0.0
    PASS   : PythonQtTestApi::initTestCase()
    PASS   : PythonQtTestApi::testCall()
    PASS   : PythonQtTestApi::testVariables()
    QDEBUG : PythonQtTestApi::testRedirect() "test" 
    QDEBUG : PythonQtTestApi::testRedirect() "" 
    QDEBUG : PythonQtTestApi::testRedirect() "
    " 
    PASS   : PythonQtTestApi::testRedirect()
    QDEBUG : PythonQtTestApi::testImporter() "# c:\test/bla/__init__.pyc has bad pyc data
    " 
    QDEBUG : PythonQtTestApi::testImporter() "# c:\test/bla/__init__.pyo has bad pyc data
    " 
    PASS   : PythonQtTestApi::testImporter()
    QDEBUG : PythonQtTestApi::testQColorDecorators() "ValueError" 
    QDEBUG : PythonQtTestApi::testQColorDecorators() ": " 
    QDEBUG : PythonQtTestApi::testQColorDecorators() "Could not find matching overload for given arguments:
    (1, 2)
     The following slots are available:
    QColor* QColor()
    QColor* QColor(uint rgb)
    QColor* QColor(int r, int g, int b)
    QColor* QColor(int r, int g, int b, int a)
    QColor* QColor(QString name)
    QColor* QColor(QColor color)
    QColor* QColor(Qt::GlobalColor color)
    " 
    QDEBUG : PythonQtTestApi::testQColorDecorators() "
    " 
    XFAIL  : PythonQtTestApi::testQColorDecorators() Testing non-existing constructor
       Loc: [PythonQtTests.cpp(518)]
    FAIL!  : PythonQtTestApi::testQColorDecorators() '(_main.evalScript("PythonQt.Qt.QColor(PythonQt.Qt.Qt.red)" ,Py_eval_input).value<QColor>()) == QColor(Qt::red)' returned FALSE. ()
       Loc: [PythonQtTests.cpp(521)]
    FAIL!  : PythonQtTestApi::testQtNamespace() 'PythonQtObjectPtr(_main.getVariable("PythonQt.QtCore.Qt.escape"))' returned FALSE. ()
       Loc: [PythonQtTests.cpp(492)]
    PASS   : PythonQtTestApi::testConnects()
    PASS   : PythonQtTestApi::testProperties()
    QDEBUG : PythonQtTestApi::testDynamicProperties() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestApi::testDynamicProperties() "  File "<string>", line 1, in <module>
    " 
    QDEBUG : PythonQtTestApi::testDynamicProperties() "AttributeError" 
    QDEBUG : PythonQtTestApi::testDynamicProperties() ": " 
    QDEBUG : PythonQtTestApi::testDynamicProperties() "Dynamic property 'testProp' does not accept an object of type NoneType (None)" 
    QDEBUG : PythonQtTestApi::testDynamicProperties() "
    " 
    PASS   : PythonQtTestApi::testDynamicProperties()
    PASS   : PythonQtTestApi::cleanupTestCase()
    Totals: 9 passed, 2 failed, 0 skipped
    ********* Finished testing of PythonQtTestApi *********
    ********* Start testing of PythonQtTestSignalHandler *********
    Config: Using QTest library 5.0.0, Qt 5.0.0
    PASS   : PythonQtTestSignalHandler::initTestCase()
    Unknown type that can not be converted to Python: 0, in PythonQtConversion.cpp:197
    FAIL!  : PythonQtTestSignalHandler::testSignalHandler() '_helper->emitEnumSignal(PQCppObject2::TestEnumValue2)' returned FALSE. ()
       Loc: [PythonQtTests.cpp(326)]
    PASS   : PythonQtTestSignalHandler::testRecursiveSignalHandler()
    PASS   : PythonQtTestSignalHandler::cleanupTestCase()
    Totals: 3 passed, 1 failed, 0 skipped
    ********* Finished testing of PythonQtTestSignalHandler *********
    ********* Start testing of PythonQtTestSlotCalling *********
    Config: Using QTest library 5.0.0, Qt 5.0.0
    PASS   : PythonQtTestSlotCalling::initTestCase()
    PASS   : PythonQtTestSlotCalling::testNoArgSlotCall()
    PASS   : PythonQtTestSlotCalling::testPODSlotCalls()
    PASS   : PythonQtTestSlotCalling::testCPPSlotCalls()
    XFAIL  : PythonQtTestSlotCalling::testQVariantSlotCalls() Testing to pass a map and compare with a different map
       Loc: [PythonQtTests.cpp(210)]
    PASS   : PythonQtTestSlotCalling::testQVariantSlotCalls()
    QDEBUG : PythonQtTestSlotCalling::testObjectSlotCalls() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testObjectSlotCalls() "  File "<string>", line 1, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testObjectSlotCalls() "ValueError" 
    QDEBUG : PythonQtTestSlotCalling::testObjectSlotCalls() ": " 
    QDEBUG : PythonQtTestSlotCalling::testObjectSlotCalls() "Called QWidget* getQWidget(QWidget* obj) with wrong arguments: (PythonQtTestSlotCallingHelper (PythonQtTestSlotCallingHelper at: 0x18812b0),)" 
    QDEBUG : PythonQtTestSlotCalling::testObjectSlotCalls() "
    " 
    XFAIL  : PythonQtTestSlotCalling::testObjectSlotCalls() Testing to pass a QObject when another object was expected
       Loc: [PythonQtTests.cpp(220)]
    PASS   : PythonQtTestSlotCalling::testObjectSlotCalls()
    PASS   : PythonQtTestSlotCalling::testMultiArgsSlotCall()
    PASS   : PythonQtTestSlotCalling::testPyObjectSlotCall()
    FAIL!  : PythonQtTestSlotCalling::testOverloadedCall() '_helper->runScript("obj.overload(12); obj.setPassed();\n", 2)' returned FALSE. ()
       Loc: [PythonQtTests.cpp(149)]
    Unknown type that can not be converted to Python: 0, in PythonQtConversion.cpp:197
    QDEBUG : PythonQtTestSlotCalling::testCppFactory() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testCppFactory() "  File "<string>", line 1, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testCppFactory() "AttributeError" 
    QDEBUG : PythonQtTestSlotCalling::testCppFactory() ": " 
    QDEBUG : PythonQtTestSlotCalling::testCppFactory() "'NoneType' object has no attribute 'getH'" 
    QDEBUG : PythonQtTestSlotCalling::testCppFactory() "
    " 
    FAIL!  : PythonQtTestSlotCalling::testCppFactory() '_helper->runScript("if obj.getPQCppObjectNoWrapAsValue().getH()==47: obj.setPassed();\n")' returned FALSE. ()
       Loc: [PythonQtTests.cpp(243)]
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "  File "<string>", line 2, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "ValueError" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() ": " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Called ClassA* getClassAPtr(ClassA* o) with wrong arguments: (ClassB (C++ object at: 0x188ec70),)" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "
    " 
    XFAIL  : PythonQtTestSlotCalling::testInheritance() ClassB can not be converted to ClassA
       Loc: [PythonQtTests.cpp(95)]
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "  File "<string>", line 2, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "ValueError" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() ": " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Called ClassB* getClassBPtr(ClassB* o) with wrong arguments: (ClassA (C++ object at: 0x188cf70),)" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "
    " 
    XFAIL  : PythonQtTestSlotCalling::testInheritance() ClassA can not be converted to ClassB
       Loc: [PythonQtTests.cpp(100)]
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "  File "<string>", line 2, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "ValueError" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() ": " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Called ClassC* getClassCPtr(ClassC* o) with wrong arguments: (ClassA (C++ object at: 0x1892d70),)" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "
    " 
    XFAIL  : PythonQtTestSlotCalling::testInheritance() ClassA can not be converted to ClassC
       Loc: [PythonQtTests.cpp(106)]
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "  File "<string>", line 2, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "ValueError" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() ": " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Called ClassC* getClassCPtr(ClassC* o) with wrong arguments: (ClassB (C++ object at: 0x1893290),)" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "
    " 
    XFAIL  : PythonQtTestSlotCalling::testInheritance() ClassB can not be converted to ClassC
       Loc: [PythonQtTests.cpp(108)]
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Traceback (most recent call last):
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "  File "<string>", line 2, in <module>
    " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "ValueError" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() ": " 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "Called ClassC* getClassCPtr(ClassC* o) with wrong arguments: (ClassD (ClassD at: 0x1893990),)" 
    QDEBUG : PythonQtTestSlotCalling::testInheritance() "
    " 
    XFAIL  : PythonQtTestSlotCalling::testInheritance() ClassD can not be converted to ClassC
       Loc: [PythonQtTests.cpp(111)]
    PASS   : PythonQtTestSlotCalling::testInheritance()
    FAIL!  : PythonQtTestSlotCalling::testAutoConversion() '_helper->runScript("if obj.setAutoConvertColor(PythonQt.QtCore.Qt.red)==PythonQt.Qt.QColor(PythonQt.QtCore.Qt.red): obj.setPassed();\n")' returned FALSE. ()
       Loc: [PythonQtTests.cpp(130)]
    PASS   : PythonQtTestSlotCalling::cleanupTestCase()
    Totals: 10 passed, 3 failed, 0 skipped
    ********* Finished testing of PythonQtTestSlotCalling *********
    Tests failed: 6
    

    'Qt::escape' doesn't exist any more in Qt5, so this error is ok; I don't have an idea what's wrong there in the other cases.
    I should also mention here that I needed to change calls to 'qVariantValue<Type>( var )' to 'var.value<Type>()', but I assumed that should be fine…

    I can also send you the code (the whole "PythonQt2.1_Qt5.0.0.zip" and/or just my changes for the version with Qt4.6.2 API).
    I would also appreciate it if my changes were integrated in PythonQt…

     
  • Melven Röhrig-Zöllner

    And in our application I've got further problems:
    There is a segmentation fault, when I call a public slot that returns a QList from within python…
    So there are probably some more problems that just didn't occur yet!

     
  • Melven Röhrig-Zöllner

    Ok I found one of the problems: the QMetaType::Type definitions have changed… especially Unknown (was -1, now 0) and void (was 0, now 43). I will try to find all places in the code where these definitions are used and try the tests again.

     
  • Melven Röhrig-Zöllner

    Fixed the above problem and removed some bugs in my changes (assignement of temporary QByteArray to const char*) and now it seems to work fine: All tests succeeded (except the "Qt::escape"-test, because the function is missing in Qt5) and the examples work, too.

    I also tried some stuff from the Qt_All-extension… e.g. opening an url in a QWebView works as well.

     
  • Florian Link

    Florian Link - 2013-01-24

    This is great news! Are you planning to submit a patch so that I can merge your changes to PythonQt?

     
  • Melven Röhrig-Zöllner

    So here is a zip-file with the patch: https://gigamove.rz.rwth-aachen.de/d/id/X2sXDqrfX8ESyj

    The archive contains the following files:

    * PythonQt2.1_Qt4.6.2_qt5_v1_core.patch: patch-file for the core-pythonqt (e.g. src-folder)
    * PythonQt2.1_Qt4.6.2_qt5_v1_extensions.patch: patch-file for the QtAll-extension (e.g. extensions-folder)
    These two patches above should be fully compatible with Qt4…

    * PythonQt2.1_Qt4.6.2_qt5_v1_tests.patch: patch-file for the tests
    * PythonQt2.1_Qt4.6.2_qt5_v1_examples: patch file for the examples
    I have not tested my changes for the examples and tests in Qt4, the main difference is that I exchanged qVariantValue with qvariant_cast, so I assume this should run in Qt4, too.

    * generated_cpp.zip: generated code for qt 5.0.0, including the necessary  "builtin"-part and the generated code for the QtAll-extension
    * generator.zip: the (modified) code-generator including new typesystem-files (and very few modifications in the source-code itself)

    * PythonQt2.1_Qt5.0.0_v1.zip: complete archive with all necessary files

    Here I want to remark that I may have missed further incompatibilities between Qt4 and Qt5, so it should not be used in a productive environment, yet.

     
  • Sergey

    Sergey - 2013-02-24

    Thanks! PythonQt2.1_Qt5.0.0_v1.zip works in Windows and Ubuntu.

     
  • Anonymous

    Anonymous - 2013-04-04

    Could you share PythonQt2.1_Qt5.0.0_v1.zip again? The link on GigaMove is not valid anymore.

     
  • Melven Röhrig-Zöllner

    So here is a new link: https://gigamove.rz.rwth-aachen.de/download/id/wiYwqFtrBgXKR8

    It's just the PythonQt2.1_Qt5.0.0_v1.zip and does not include the patches…

    But to make it clear again: the idea was that the PythonQt developers could have a look at it and possibly merge the changes somehow; it needs further testing and is probably not very stable or functional.
    In my application it seems to work fine, but currently we've only some simple pythonqt-scripts and do not use many of the features of PythonQt.

     
  • Florian Link

    Florian Link - 2013-04-05

    Yes, as I am the "PythonQt developers", I guess I should comment about this.

    I had a look at melven's patch and it looks fine to me (regarding the core PythonQt library). I think melven found all major issues, especially the changed Metatypes, but there might be border cases that are not yet covered…

    Regarding the integration, I did not have time yet to integrate it into PythonQt trunk and can't promise anything in the near future.

    I will definitely do a complete port (including the code generation)  to Qt5 when we switch MeVisLab to Qt 5.x, but that is not yet on our schedule.

    regards,
    Florian

     
  • Sergey

    Sergey - 2013-04-06

    We wait!

     
  • Melven Röhrig-Zöllner

    Hello again,

    in the meantime we have made some further modifications on our version of PythonQt:

    There are now different directories for the generated files for Qt5 and Qt4.
    And qmake should choose automatically the correct version.

    Additionally I've implemented an example for a nice pythonqt-console with
    highlighting, autocompletion and support for text input from the user.
    You can have a look at it or use it, but it may not be working properly;
    it was intended as a draft for the console we want to use in our project.

    I also merged the latest version from the svn repository (svn version 244).

    Florian, I can also send you a git repository with my changes by email, but it
    contains quite a lot of small changes...

     

    Last edit: Melven Röhrig-Zöllner 2013-05-28
    • Sergey

      Sergey - 2014-04-30

      Maybe it's time to move Melven version into main branch? It works flawlessly.

       
  • Florian Link

    Florian Link - 2013-05-28

    Thanks, please mail me the git repository.

     
  • Orochimarufan

    Orochimarufan - 2013-07-30

    I picked up the pythonqt.zip and merged it into my fork at https://github.com/Orochimarufan/PythonQt
    Feel free to take a look at it. Note that the qmake build system might not be up-to-date.

     
  • Clemens Nyffeler

    Hi, I'm new to PythonQt but I would like to use it for a personal project. I downloaded from the repository you mentioned (https://github.com/Orochimarufan/PythonQt.git) using git. But when I try to build it I get all the same errors that I got when using the PythonQt2.1_Qt4.6.2 version.

    In particular the notorious, "base operand of ‘->’ has non-pointer type" error for CodeModelPointer.

    I guess I must be doing something wrong in the build process. I used the instructions from here for Linux. Should I use cmake instead? (I'm not familiar and would have to learn how to use it)

     
  • Florian Link

    Florian Link - 2014-09-08

    I reimplemented/merged the Qt5 and Python 3 support into the official PythonQt svn (on the trunk). I used some helper methods and extra porting defines so that less code is touched than in the original contribution.

    Thanks again for the contribution to everyone!

    PythonQt now supports Qt5 (tested with Qt 5.0 and Qt 5.3) and Python 3 (tested with Python 3.4, Python 3.3 is required because of some C-API calls that we do).

    The CMakeFiles have not been adapted yet, since I have several contributions that all do thinks differently and contain TODO notes... I am not a CMake expert, I hope still have enough time to get that running as well.

    I did not yet merge the doc decorator extension that was contained in the above mentioned repository, I will have a look at that feature later on.

     
  • Florian Link

    Florian Link - 2014-09-09

    I had a look at the different CMakeFiles and decided that I will not invest the time to get that sorted out. Maybe someone steps up and contributes working CMakeFiles that support all features:

    • Qt4 and Qt5
    • Python 2 and Python 3
    • Building Qt wrappers into PythonQt directly
    • Building the pythonqt_generator with both Qt4 and Qt5 (without doubling the sources/CMakefiles)
    • Building all examples and the unittest with Qt4/Qt5

    It would be nice if you can give me some feedback how well the svn trunk works for you guys.

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.