Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Shiboken2: std::function or any "SLOT" type
Forum Updated to NodeBB v4.3 + New Features

Shiboken2: std::function or any "SLOT" type

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 273 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fabien-B
    wrote on last edited by
    #1

    Hello,
    I am trying to generate shiboken bindings for a lib that use std::function. How can I do that ?

    I have this struct:

    struct Callback {
        std::function<void(Peer* sender, QStringList params)> cb;
        QObject* context;
    };
    

    When I generate shiboken bindings for it, the cb field disappear, as seen in this extract of the python help:

     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  context
    

    I can modify the original library is needed, so I have two questions:

    • How can I generate bindings for std::function?
    • If this is not possible or hard to do, is there a way to declare a slot type?

    Thanks

    1 Reply Last reply
    0
    • CristianMaureiraC Offline
      CristianMaureiraC Offline
      CristianMaureira
      wrote on last edited by
      #2

      Hey,
      you can check the code of existing bindings that workaround std::function arguments. You can look into the implementation of QThreadPool.start(std::function) binding, which internally accepts a PyCallable.
      Here you have the change: https://codereview.qt-project.org/c/pyside/pyside-setup/+/369427

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved