博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QtGui.QSplitter
阅读量:6837 次
发布时间:2019-06-26

本文共 2247 字,大约阅读时间需要 7 分钟。

QtGui.QSplitter lets the user control the size of child widgets by dragging the boundary between the children. In our example, we show three QtGui.QFrame widgets organized with two splitters.

#!/usr/bin/python# -*- coding: utf-8 -*-"""ZetCode PyQt4 tutorial This example showshow to use QtGui.QSplitter widget. author: Jan Bodnarwebsite: zetcode.com last edited: September 2011"""import sysfrom PyQt4 import QtGui, QtCoreclass Example(QtGui.QWidget):        def __init__(self):        super(Example, self).__init__()                self.initUI()            def initUI(self):              hbox = QtGui.QHBoxLayout(self)        topleft = QtGui.QFrame(self)        topleft.setFrameShape(QtGui.QFrame.StyledPanel)         topright = QtGui.QFrame(self)        topright.setFrameShape(QtGui.QFrame.StyledPanel)        bottom = QtGui.QFrame(self)        bottom.setFrameShape(QtGui.QFrame.StyledPanel)        splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal)        splitter1.addWidget(topleft)        splitter1.addWidget(topright)        splitter2 = QtGui.QSplitter(QtCore.Qt.Vertical)        splitter2.addWidget(splitter1)        splitter2.addWidget(bottom)        hbox.addWidget(splitter2)        self.setLayout(hbox)        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))                self.setGeometry(300, 300, 300, 200)        self.setWindowTitle('QtGui.QSplitter')        self.show()        def main():        app = QtGui.QApplication(sys.argv)    ex = Example()    sys.exit(app.exec_())if __name__ == '__main__':    main()

In our example, we have three frame widgets and two splitters.

topleft = QtGui.QFrame(self)topleft.setFrameShape(QtGui.QFrame.StyledPanel)

We use a styled frame in order to see the boundaries between the QtGui.QFrame widgets.

splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal)splitter1.addWidget(topleft)splitter1.addWidget(topright)

We create a QtGui.QSplitter widget and add two frames into it.

splitter2 = QtGui.QSplitter(QtCore.Qt.Vertical)splitter2.addWidget(splitter1)

We can also add a splitter to another splitter widget.

QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))

We use a Cleanlooks style. In some styles the frames are not visible.

QtGui.QSplitter widgetFigure: QtGui.QSplitter widget

转载地址:http://cuqkl.baihongyu.com/

你可能感兴趣的文章
关于SSI整合之CRUD
查看>>
生产者/消费者模型
查看>>
reset代码
查看>>
阿里,百度,腾讯,360,新浪,网易,小米等开源项目
查看>>
gitshell 基础操作
查看>>
HDU 1517 A Multiplication Game 博弈
查看>>
调整字符串日期的格式
查看>>
paramiko多线程远程执行命令
查看>>
vue-computed计算属性用法
查看>>
mysql学习笔记-day1
查看>>
Atcoder Beginner Contest 118 D-Match Matching(完全背包)
查看>>
Webapi创建和使用 以及填坑(三)
查看>>
oracle-sql系统学习-ddl-dml
查看>>
java创建文件写入内容,并实现下载该文件
查看>>
C# Graphics 字体倒置
查看>>
Cisco Easy ***综合配置示例
查看>>
18岁的他从月薪2000到月薪11000经历了什么?
查看>>
Cloud Service Process Pack
查看>>
rsync应用拓展多模块同步13
查看>>
FreeBSD下安装配置Hadoop集群(一)
查看>>