Unsolved Is there a way to send a key press to a widget without having to move the mouse over it?
-
@mrjj said in Is there a way to send a key press to a widget without having to move the mouse over it?:
dumpObjectTree
Thanks, I have to check that viewport method, I didn't see that before.
Basically I tried another widget I normally work on and that accepted the key. But this widget, no key I sent, were accepted.
I call dumpObjectTree method but it doesn't print anything, I guess it only works in IDE environments?
But I acquire the widget currently using widgetAt method and after that I recursively gathered all of its children which are these:
<PySide2.QtWidgets.QWidget object at 0x000000006CDA9DC8>
[<PySide2.QtWidgets.QWidget object at 0x000000006CDA9DC8>, <PySide2.QtWidgets.QWidget object at 0x000000009B3FC508>, <PySide2.QtWidgets.QWidget object at 0x000000006CDA9E88>, <PySide2.QtWidgets.QWidget object at 0x000000009B5E6A88>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B42B948>, <PySide2.QtWidgets.QWidget object at 0x000000009B42B7C8>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B42B108>, <PySide2.QtWidgets.QWidget object at 0x000000009B42B1C8>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B42BFC8>, <PySide2.QtWidgets.QWidget object at 0x000000009B2A2D88>, <PySide2.QtWidgets.QWidget object at 0x000000009B316CC8>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B316D08>, <PySide2.QtWidgets.QWidget object at 0x000000009B40FDC8>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B316BC8>, <PySide2.QtWidgets.QWidget object at 0x000000009B316C08>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B316A08>, <PySide2.QtWidgets.QWidget object at 0x000000009B3169C8>, <PySide2.QtWidgets.QWidget object at 0x000000009B3174C8>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B3170C8>, <PySide2.QtWidgets.QWidget object at 0x000000009B317848>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B317388>, <PySide2.QtWidgets.QWidget object at 0x000000009B3173C8>, <PySide2.QtWidgets.QWidget object at 0x000000009B317A48>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B3175C8>, <PySide2.QtWidgets.QWidget object at 0x000000009B317148>, <PySide2.QtWidgets.QVBoxLayout object at 0x000000009B317D88>]Not sure if that helps. Unfortunately in this app, this is how you have to blindly find the widget you are looking for.
-
Hi
But this widget, no key I sent, was accepted.
Ok so that often would mean that its not the right widget we send to.
It should work the same (event wise) regardless of the widget but
if nothing happens it smell like it's not hooked up as we think or similar.- I call dumpObjectTree method but it doesn't print anything, I guess it only works in IDE environments?
Oh, i assumed it uses the qDebug method as it comes the same place but you could be right.
Hmm,. it only shows QVBoxLayout names.
Do/can you call widgetprt->metaObject()->className()
so we maybe could see the it better ?Also just to be sure. We are talking about this one
One thing I might try if all else fails is to install an event filter (if that works in python)
on the ListView (or what it is )
and see what is sent to it when you press the key. - I call dumpObjectTree method but it doesn't print anything, I guess it only works in IDE environments?
-
@mrjj Thanks, when I call metaObject().className() I get these:
QWidget
QWidget
QWidget
QWidget
QVBoxLayout
QWidget
QVBoxLayout
QWidget
QVBoxLayout
QWidget
QWidget
QVBoxLayout
QWidget
QVBoxLayout
QWidget
QVBoxLayout
QWidget
QWidget
QVBoxLayout
QWidget
QVBoxLayout
QWidget
QWidget
QVBoxLayout
QWidget
QVBoxLayoutYes that's the panel we are talking about.
Ok I will look into installing an event filter. I am not sure if that's supported so will have to check.
I also just tried sending the same key events to all the child widgets but same result.
-
Hi
Hmm ok, that normally gives the concreate class names and not just QWidget. :)Ok so is that panel. and we talk about the actual tree view there?
you have it selected (item selected) and press a key to fire the function?
Just try to understand what/where exactly you try to trigger- I also just tried sending the same key events to all the child widgets but same result.
Hmm If it is a QShortCut key, it might be registered to other parent but you say each part has
different keys so it's valid to assume its indeed added to list directly and not higher up in the panel/area.Im not a python user so I cant say if event filters works. but why not. :)
Since this a commercial project, its not possible just to ask them how to trigger this ?
-
@mrjj said in Is there a way to send a key press to a widget without having to move the mouse over it?:
Hi
Hmm ok, that normally gives the concreate class names and not just QWidget. :)Ok so is that panel. and we talk about the actual tree view there?
you have it selected (item selected) and press a key to fire the function?
Just try to understand what/where exactly you try to trigger- I also just tried sending the same key events to all the child widgets but same result.
Hmm If it is a QShortCut key, it might be registered to other parent but you say each part has
different keys so it's valid to assume its indeed added to list directly and not higher up in the panel/area.Im not a python user so I cant say if event filters works. but why not. :)
Since this a commercial project, its not possible just to ask them how to trigger this ?
Actually not just tree view but the whole panel because anywhere you invoke the key it will trigger the action.
The action I chose is called event log that will hide the tree view but show a console like control.
I guess I could ask them also. But they might not reply also as it's more like qt which sometimes they know how to help.
Because there qt support in this app is very slim, everything is raw.
-
@lachdanan
Ok, and you also tried to send to the top parent ? / the widget that holds the panel.
It sounds like a QShortcut since you dont need to click menu or button.Yeah, they might not be able to help in support but any info regarding who owns
the QShortcut would help. -
Hi,
Since the application might be built with Qt, did you consider using GammaRay to inspect it ? Using it you might find the right widget you need and activate it directly.
-
@mrjj said in Is there a way to send a key press to a widget without having to move the mouse over it?:
@lachdanan
Ok, and you also tried to send to the top parent ? / the widget that holds the panel.
It sounds like a QShortcut since you dont need to click menu or button.Yeah, they might not be able to help in support but any info regarding who owns
the QShortcut would help.Yes I just tried sending it to the mainQtWindow and placed my cursor on the right widget before running the code, same thing.
@SGaist said in Is there a way to send a key press to a widget without having to move the mouse over it?:
Hi,
Since the application might be built with Qt, did you consider using GammaRay to inspect it ? Using it you might find the right widget you need and activate it directly.
Thanks, I just looked it up, seems like a massive download but I might give this a try.
-
@SGaist
Hmm, does this KDAB GammaRay play with my Python/PySide2 Qt development instead of C++? Also, no Qt Creator for development, everything run through MS VSCode in Python mode? -
This post is deleted!