I have a GUI created by Qt Designer. One element (“screenshot”) is used as a placeholder for another class definition. It’s Python code translation looks like so:
...
class Ui_endomess(object):
def setupUi(self, endomess):
...
self.screenshot = screenshot(self.centralwidget)
...
from screenshot import screenshot
The “screenshot” class looks like so:
...
class screenshot(QGraphicsView):
...
def some_function(self):
...
Both are used by a main script with the following stucture:
...
from endomess_ui import Ui_endomess
...
class endomess(QMainWindow, Ui_endomess):
def __init__(self):
QMainWindow.__init__(self)
self.setupUi(self)
...
def main(argv):
app = QApplication(argv, True)
wnd = endomess()
wnd.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main(sys.argv)
Of course, I can manipulate GUI object from within the “endomess” class like so:
self.calibrateButton.setEnabled(True)
What I want to do is manipulate GUI elements from a function within the “screenshot” class. I messed around with “global” calls, but I just don’t know how to do it. Is this possible?
Thanks in advance for all help!
The qt-way would be to define a signal in your
screenshotclass and connect that to a slot in yourendomessclass which can then perform the modifications.From within the
screenshotclass you may also be able to access the object asself.parent().parent()(self.parent() should be thecentralWidget, and that’s parent theendomessinstance), but this may break if something in your hierarchy changes.