下面的代码创建一个QWidget窗口,其中QPushButton连接到resizeDialog()。按一个按钮将对话框的大小从.resize(200100)切换到.resize(600300),然后返回。在
问:默认情况下,从一个窗口大小到另一个窗口的转换会立即发生。如何用动画覆盖此行为?在
from PyQt4 import QtCore, QtGui
import sys
class myWindow(QtGui.QWidget):
def __init__(self, parent=None):
super(myWindow, self).__init__(parent)
myLayout = QtGui.QVBoxLayout(self)
Button = QtGui.QPushButton('Resize')
myLayout.addWidget(Button)
Button.setMinimumWidth(200)
Button.clicked.connect(self.resizeDialog)
def resizeDialog(self):
dialog.size().width()==200:
dialog.resize(600,300)
else:
dialog.resize(200,100)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
app.setApplicationName('myApp')
dialog = myWindow()
dialog.resize(200,100)
dialog.show()
sys.exit(app.exec_())
由this问题链接的source将导致以下代码。在这种情况下,从c++代码到python的转换相当简单。在
相关问题 更多 >
编程相关推荐