5

On Windows, I need to use in Python a few custom Qt5 widgets written in C++, and I have to use pyside2 because of its license.

I have been able to compile the pyside2 library from source (together with the shiboken2 examples), but I am not able to find a simple example of how to wrap a custom Qt5 widget.

I am aware that pyside2 is still not officially released, but it seems to be already used (e.g., in Maya): In a PySide2 app, how can I get the ID for a QWindow?

Can anybody give hints or directions? A minimal example would be even better.


Edits

Based on @placinta comments, I have created a repo with a minimal example that attempts to wrap a custom QMainWindow.

In my tests, I have used the pyside2 Conda package that wraps Qt 5.6.

When I execute the shiboken2 executable, I am getting tons of warnings.

I assume that these warnings are triggering a compilation error with the shiboken2 generated code.

gmas80
  • 1,218
  • 1
  • 14
  • 44
  • 1
    This is not really a complete answer, thus I post it as a comment. You can use the scriptableapplication example as a reference. It is located in the 5.9 branch of the pyside examples repo git://code.qt.io/pyside/examples.git . The example creates bindings for a QMainWindow-derived class among other things. The shiboken invocation is done by qmake when processing the scriptableapplication.pro file, which process the .xml typesystem file. – alcroito Dec 05 '17 at 09:09
  • @Placinta Thanks! Are you using `shiboken2` in a project? – gmas80 Dec 05 '17 at 15:16
  • No, I'm a developer of PySide2. – alcroito Dec 05 '17 at 17:30
  • @Placinta, this is great! It would be great if you could find the time to develop your comment into a complete answer. – gmas80 Dec 07 '17 at 12:38
  • @gmas80 https://github.com/giumas/shiboken2_minimal not found – eyllanesc Jan 24 '18 at 16:35
  • @eyllanesc sorry! just made it public – gmas80 Jan 24 '18 at 16:40
  • @eyllanesc I may have found a workaround by modifying the CMake: https://github.com/giumas/shiboken2_minimal/blob/master/CMakeLists.txt – gmas80 Jan 25 '18 at 17:27

1 Answers1

0

A problem with my initial CMake configuration was the one described here. That is, CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS has limitations so I reverted to use 'old' export headers.

However, the compilation error for the missing metaObject() member function declaration is still present. It works by manually adding the declaration since the implementation is present in the _wrapper.cpp. Although it is not really a satisfying solution, it is a starting point for other users.

A Qt ticket for the issue at https://bugreports.qt.io/browse/PYSIDE-597 .

gmas80
  • 1,218
  • 1
  • 14
  • 44