My Qt program uses a system of retrieving widget objectNames when clicked, by finding the coordinates of mousePressEvents and then finding the child widget (or the Window) at those coordinates.
This works perfectly for most widgets, but does not for the following widgets;
QScrollBox, QTableWidget, QGraphicsView, QTextEdit, QSpinBox.
These widgets (except QSpinBox) return ‘qt_scrollarea_viewport’ instead of their objectName, presumably because that is a child widget of those listed above.
Eg:
You have a QTextEdit with geometry (0,0,50,50).
Obviously the coordinates (10,10) are ‘on’ this widget.
Yet, calling parent.childAt( (10,10) ) does not return the QTextEdit.
Calling .objectName() shows that this instead is a ‘qt_scrollarea_viewport’.
If you had twenty different QTextEdits with twenty different object names, they’d all still return ‘qt_scrollarea_viewport’.
So, how do I retrieve the actual objectName of the QTextEdit, and not it’s graphical child widget (which is what I interpret a ‘viewport’ to be), given I have the coordinates of the widget?
Thanks!
PyQt4
Python 2.7.2
Windows 7
It is a child widget.
Solution: