pyside教程 Module_2_关闭按钮
?
我想下个QT designer。可是找不到。。冒是下QT Creator就行
http://qt-project.org/downloads
好吧。先装再说(d:\ide\qtcreator-2.4.1)
不行,得装QT SDK。。啊。1.7G, i am shattered
(补充:后来看到了PyQT这样一个好东西:http://www.riverbankcomputing.com/software/pyqt/download,只要下载27.6M,就包含了QT, QT designer)
?
为什么要下。因为在看这篇文章:http://qt-project.org/wiki/PySideSimplicissimus_Module_2_CloseButton
等装好了再说吧。不知要下多久!
==
不必了。QT Designer只不过是生成了一个描述ui的xml文件。http://akabaila.pcug.org.au/pyside-data/quitter.ui
继续看,no blocker.
打开这个ui文件,发现里边定义了一个按钮,一个菜单栏,像是两行两列的布局,绑定了按钮和MainWindow。就当是给button加了ActionListener而MainWindow需要去实现这个Listener。
?
接下来把这个xml转成py,竟有此等功能#_!
pyside
?
为什么没写任何代码。点button就可以关闭, 文章指出
The reason for its absence is that it has been created on the Qt Designer, which has a signal-slot editor. We used it surreptitiously(偷偷地) to connect PushButton.click() “signal” to MainWindow.close() “slot”. It is imbedded in the quitter.ui file and following the conversion, in the ui_quitter.py file. And from that file, we imported Ui_MainWindow class, which is one of the ancestors of our MainWindow class. We use Python’s multiple inheritance to facilitate use of methods in the ui_quitter.py module.
?
最后,结束之前让我再看一眼生成的xml代码(quitter.ui)
??
?
?
?