maybe, people are afraid of downloading packs, plus that, i re-wrote the script into one file as the following:
# -*- coding: utf-8 -*-
import sys
# import PyQt4 QtCore and QtGui modules
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
#from mainwindow import MainWindow
if __name__ == '__main__':
# create application
app.setApplicationName('My PyQt4 QtGui Project')
# create widget
#global w
#w = MainWindow()
#w = uic.loadUi('mainwindow.ui')
#w.setWindowTitle('My PyQt4 QtGui Project')
#w.show()
def __init__(self, parent = None):
self.ui = uic.loadUi('mainwindow.ui')
self.connect(self.ui.toolButton, SIGNAL('clicked()'), self, SLOT('quit()'))
self.ui.setWindowTitle('My PyQt4 QtGui Project')
self.ui.show()
#self.ui.setupUi(self)
def quit():
print "we'll exit now..."
quit()
MainWindow_class = MainWindow()
# connection
QObject.
connect(app,
SIGNAL('lastWindowClosed()'), app,
SLOT('quit()'))
# execute application
sys.exit(app.exec_())
# -*- coding: utf-8 -*-
import sys
# import PyQt4 QtCore and QtGui modules
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
#from mainwindow import MainWindow
if __name__ == '__main__':
# create application
app = QApplication(sys.argv)
app.setApplicationName('My PyQt4 QtGui Project')
# create widget
#global w
#w = MainWindow()
#w = uic.loadUi('mainwindow.ui')
#w.setWindowTitle('My PyQt4 QtGui Project')
#w.show()
class MainWindow(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.ui = uic.loadUi('mainwindow.ui')
self.connect(self.ui.toolButton, SIGNAL('clicked()'), self, SLOT('quit()'))
self.ui.setWindowTitle('My PyQt4 QtGui Project')
self.ui.show()
#self.ui.setupUi(self)
def quit():
print "we'll exit now..."
quit()
MainWindow_class = MainWindow()
# connection
QObject.connect(app, SIGNAL('lastWindowClosed()'), app, SLOT('quit()'))
# execute application
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
my application does run, but, it doesn't connect the button to the slot it do nothing, & tells me that:
Object::connect: No such slot MainWindow::quit()
Object::connect: (sender name: 'toolButton')
Object::connect: No such slot MainWindow::quit()
Object::connect: (sender name: 'toolButton')
To copy to clipboard, switch view to plain text mode
what's the problem & how to solve it now??
pls, help me i'm a real newbie..
Bookmarks