0

It seems that QScreenRayCaster cannot be used in Python via PySide 2.

def __init__(self):
    # some code
    self.screen_ray_caster = Qt3DRender.QScreenRayCaster(self.root_entity)
    # some code

def some_mouse_event(self, e):
    self.screen_ray_caster.trigger(e.pos())
    self.screen_ray_caster.hits()

And error is thrown:

AttributeError: 'PySide2.Qt3DRender.Qt3DRender.QScreenRayCaster' object has no attribute 'hits'

I also tried to get information via signals and so I wrote this line:

self.screen_ray_caster.hitsChanged.connect(self.test)

Sadly this method has never been called.

Is there another way to to get information gained by ray caster?

Matphy
  • 1,086
  • 13
  • 21
  • 1
    Does it have to be a ray caster? You could have a look at QObjectPicker. Other than that it looks like they have forgotten to implement the method... Maybe you can extend it yourself. – Florian Blume Jul 21 '18 at 14:46
  • Yes, in some cases I use `QObjectPicker`. But for one case I really need `QScreenRayCaster`. – Matphy Jul 23 '18 at 06:09
  • 1
    My suggestion would be to file a bug report here: https://bugreports.qt.io/secure/Dashboard.jspa. According to the documentation, QAbstractRayCaster has been part of Qt3D since 5.11, so it's relatively new and I assume that they forgot the function. If you need the function right now you could try to write your own wrapper, there is some explanation here: https://stackoverflow.com/questions/41825296/python-support-for-qt-dll. May I ask what project you're creating? I'm intrigued ;) – Florian Blume Jul 23 '18 at 07:15
  • Thanks. I reported this error. – Matphy Jul 23 '18 at 07:36

0 Answers0