python - QMainWindow.close doesn't close the window despite event.accept on closeEvent -


i'm trying write application utilizes qmainwindow , has qmenubar there file->exit functionality, uses uic files. i've stripped project down part doesn't work despite efforts - closeevent called, gets accepted, window doesn't close. here's test.py:

#! /usr/bin/env python # -*- coding: utf-8 -*-  __future__ import print_function  import sys pyqt4 import qtcore, qtgui, uic  class truedit(qtgui.qmainwindow):     def __init__(self):         qtgui.qdialog.__init__(self)          self.ui = uic.loadui("test.ui")         self.ui.show()          self.ui.actionwyj_cie.triggered.connect(self.wyjscie)      def wyjscie(self):         self.close()      def closeevent(self, event):         event.accept()         print("wtf, still alive")      @qtcore.pyqtslot()     def reject(self):         print("never entered this")         return none   if __name__=="__main__":     app = qtgui.qapplication(sys.argv)     app.setquitonlastwindowclosed(true)     window = truedit()     sys.exit(app.exec_()) 

and here's test.ui:

<?xml version="1.0" encoding="utf-8"?> <ui version="4.0">  <class>mainwindow</class>  <widget class="qmainwindow" name="mainwindow">   <property name="geometry">    <rect>     <x>0</x>     <y>0</y>     <width>800</width>     <height>600</height>    </rect>   </property>   <property name="windowtitle">    <string>mainwindow</string>   </property>    <widget class="qmenubar" name="menubar">    <property name="geometry">     <rect>      <x>0</x>      <y>0</y>      <width>800</width>      <height>21</height>     </rect>    </property>     <widget class="qmenu" name="menuplik">     <property name="title">      <string>plik</string>     </property>     <addaction name="actionwyj_cie"/>    </widget>    <addaction name="menuplik"/>   </widget>   <widget class="qstatusbar" name="statusbar">    <property name="statustip">     <string/>    </property>   </widget>   <action name="actionwyj_cie">    <property name="text">     <string>wyjście</string>    </property>    <property name="shortcut">     <string>ctrl+k</string>    </property>   </action>  </widget>  <resources/>  <connections/> </ui> 

what have done wrong?

you might find better answer here

pyqt: clicking x doesn't trigger closeevent

it seems problem lies within,

    self.ui = uic.loadui("test.ui")     self.ui.show() 

where instance being created called self.ui


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -