Is there a PyQT equivalent to wx.FutureCall (calling a function after window is initialized and drawn)?

后端 未结 1 2040
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 13:03

I am trying to delay setting variables after my main window is opened. I have tried showEvent() but that doesn\'t work. I know in wxPython there is wx.FutureCall method to u

相关标签:
1条回答
  • 2020-11-29 13:07

    I don't know why showEvent is not working for you. For me it is working as expected. It is fired after the window is shown.

    For the delayed call, you can use QTimer.singleShot:

    class MyWindow(QtGui.QMainWindow):
      def __init__(self, parent=None):
    
        QtGui.QWidget.__init__(self, parent)
    
        ... init stuff here...
    
        QtCore.QTimer.singleShot(500, self.OnLoad)
    
      def OnLoad(self):
        ... my stuff here...
    
    0 讨论(0)
提交回复
热议问题