How to detect keypresses inside FreeCAD window without creating a qt widget

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
ryn
Posts: 12
Joined: Tue Jun 14, 2022 7:50 pm

How to detect keypresses inside FreeCAD window without creating a qt widget

Post by ryn »

I've seen that a lot of macros use pyside and I know Qt's "mainwindow" class has a key-press event handler inside it, is there a way to detect key-presses inside the FreeCAD window like you can with other apps that have without having to create a new qt widget?
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: How to detect keypresses inside FreeCAD window without creating a qt widget

Post by openBrain »

You can install an eventFilter in the QApplication. However, depending on your exact Qt version, there were bugs in PySide2 that would crash FreeCAD in such a situation.
mario52
Veteran
Posts: 4673
Joined: Wed May 16, 2012 2:13 pm

Re: How to detect keypresses inside FreeCAD window without creating a qt widget

Post by mario52 »

Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
Post Reply