简体   繁体   中英

Close button in qt4 not working

Here is my code:

self.retranslateUi(MainWindow)
    QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.destroy)

When i run my program it says:

File "myui.py", line 52 QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.destroy) ^ IndentationError: unexpected indent

Are you using PySide or PyQt? You should be using new-style signals and slots, either way. For me, or anybody for that matter to give a more useful answer you should really provide more details - more code, what you've tried already that didn't work, etc. Make sure you've correctly defined destory(), it's in-scope or imported or whatever, and switch to new-style signals/slots. Shouldn't be too hard from there.

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM