I have a problem trying to hide/show my widget.
This is an example of what I have:
main.py
def __init__(self):
self.gui = Gui()
def onMyCustomEvent(self):
self.gui.showOrHide() #<---- SEGFAULT
window = Main()
sys.exit(app.exec_())
class Main(QMainWindow):
def __init__(self):
QMainWindow.__init__(self, parent=None)
self.gui = Gui()
def onMyCustomEvent(self):
self.gui.showOrHide() #<---- SEGFAULT
app = QtGui.QApplication(sys.argv)
window = Main()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
gui.py
def __init__(self):
QWidget.__init__
(self, parent
=None
) #set size of widget
#set title
#.....
#.....
def showOrHide(self):
if self.isVisible():
self.setVisible(False)
else:
self.setVisible(True)
class Gui(QWidget):
def __init__(self):
QWidget.__init__(self, parent=None)
#set size of widget
#set title
#.....
#.....
def showOrHide(self):
if self.isVisible():
self.setVisible(False)
else:
self.setVisible(True)
To copy to clipboard, switch view to plain text mode
So, this is the code, and when I try to show or hide the gui, I get a SEGFAULT or a message saying "QCoreApplication::sendPostedEvents: Cannot send posted events for objects in another thread". The SEGFAULT and the message appear randomly.
I have searched and the message means that I must use processEvent, postEvent and so on because I'm trying to access a gui from another thread, but I'm _not_! I don't use threads in my app, so I'm a little confused.
Why could be happening?
Thanks
Bookmarks