Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind class that accepts object from external package #55

Open
kerim371 opened this issue Jul 20, 2021 · 0 comments
Open

Bind class that accepts object from external package #55

kerim371 opened this issue Jul 20, 2021 · 0 comments
Labels
question Further information is requested

Comments

@kerim371
Copy link

Hi,

I have simple class:

#ifndef __qColadaTreeTEST_h
#define __qColadaTreeTEST_h

// Qt includes
#include <QTreeView>

// Colada includes
#include "qColadaAppExport.h"

// h5gt includes
#include <h5gt/H5File.hpp>  // has python bindings using pybind11 

class Q_COLADA_APP_EXPORT qColadaTreeTEST : public QTreeView {
  Q_OBJECT

public:
  explicit qColadaTreeTEST(QWidget *parent = nullptr);
  ~qColadaTreeTEST() = default;

public slots:
  bool addH5File(h5gt::File file);  // file -  is of type `h5gt::File` -> it has python bindings
};

#endif

as you can see it accepts h5gt::File file wich is not Qt based C++ class. But h5gt library has python bindings done with pybind11 so it is accessible from python.

When qColadaTreeTEST is binded via PythonQt I cannot call addH5File with h5gt.File argument as it gives me an error:

import qColadaAppPythonQt
q = qColadaAppPythonQt.qColadaTreeTEST()

from h5gtpy import h5gt
file_name = 'D:/test.h5'
file = h5gt.File(file_name, h5gt.OpenFlag(h5gt.ReadWrite | h5gt.Create | h5gt.Truncate))

q.addH5File(file)   # here I get the following error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
ValueError: Called addH5File(h5gt::File file) -> bool with wrong arguments: (<h5gtpy._h5gt.File object at 0x00000285128901F0>,)

How to tell PythonQt that h5gt::File C++ class is the same as h5gtpy._h5gt.File in Python?

@mrbean-bremen mrbean-bremen added the question Further information is requested label Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants