Reputation: 1754
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!
Upvotes: 1
Views: 127
Reputation: 69082
The qt-way would be to define a signal in your screenshot
class and connect that to a slot in your endomess
class which can then perform the modifications.
From within the screenshot
class you may also be able to access the object as self.parent().parent()
(self.parent() should be the centralWidget
, and that's parent the endomess
instance), but this may break if something in your hierarchy changes.
Upvotes: 2