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 shows
how to use QtGui.QSplitter widget. author: Jan Bodnar
website: zetcode.com
last edited: September 2011
""" import sys
from PyQt4 import QtGui, QtCore class 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.

Figure: QtGui.QSplitter widget

QtGui.QSplitter的更多相关文章

  1. QListWidget特别简单,但有两种添加item的方式

    虽然特别简单,但是对于小白来说,还是有必要过一下脑子和眼睛,当然还得过手(江湖传言:眼过千变,不如手过一遍),所以记录在此: #include "tablewidgetxxx.h" ...

  2. ZetCode PyQt4 tutorial widgets II

    #!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...

  3. 读Pyqt4教程,带你入门Pyqt4 _009

    QLineEdit QLineEdit 窗口组件用来输入或者编辑单行纯文本,有撤销/重做,剪切/粘贴和拖放功能. #!/usr/bin/python # -*- coding: utf-8 -*- # ...

  4. 【转载】Pyqt QSplitter分割窗口

    转载来自: http://blog.sina.com.cn/s/blog_4b5039210100h3ih.html 分割窗口在应用程序中经常用到,它可以灵活分布窗口布局,经常用于类似文件资源管理器的 ...

  5. Qt浅谈之四十五QSplitter实现自由伸缩滑动窗口

    一.简介 最近看到一篇Qt实现伸缩滑动的窗口的文章,但其代码不完整.便在此重新书写了完整的代码,并开源出来.窗口的中央有滑动条可以动态改变子窗口的大小,隐藏的按钮可以快速伸缩子窗口.其效果图如下: 二 ...

  6. somethings about QSplitter

    m_splitter = new QSplitter(Qt::Horizontal);    m_splitter->addWidget(this->m_leftWidget);    m ...

  7. Qt布局与分割器QSplitter

    Qt的布局方式主要有四种:   QGridLayout         栅格布局 QFormLayout       表格布局 QHBoxLayout       水平布局 QVBoxLayout   ...

  8. PySide中QtGui.QFrame的用法

    最近一位同事的出现让我重新正视PySide中designer这个工具的强大之处,通过QtGui.QObject.setGeometry(QtCore.QRect())这个最简单直接的方法可以完成很多复 ...

  9. 拆分窗口QSplitter

    拆分窗口中可以添加许多子控件,各个子控件通过拆分线相互分隔开来,拖动该拆分线可以随意改变子控件大小 import sys from PyQt5.QtCore import Qt from PyQt5. ...

随机推荐

  1. Codeforces 839D Winter is here(容斥原理)

    [题目链接] http://codeforces.com/contest/839/problem/D [题目大意] 给出一些数,求取出一些数,当他们的GCD大于0时,将数量乘GCD累加到答案上, 求累 ...

  2. bozj 1449/2895: 球队预算 -- 费用流

    2895: 球队预算 Time Limit: 10 Sec  Memory Limit: 256 MB Description 在一个篮球联赛里,有n支球队,球队的支出是和他们的胜负场次有关系的,具体 ...

  3. HDU 5651 xiaoxin juju needs help 数学

    xiaoxin juju needs help 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5651 Description As we all k ...

  4. hdu 1024 Max Sum Plus Plus DP

    Max Sum Plus Plus Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php ...

  5. hihocoder 1519 : 逃离迷宫II

    题目链接 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi被坏女巫抓进里一间有N x M个格子组成的矩阵迷宫. 有些格子是小Hi可以经过的,我们用'.'表示:有些格 ...

  6. Hive伪分布式下安装

    本安装过程只作为个人笔记用,非标准教程,请酌情COPY.:-D Hive下载 下载之前,需先查看兼容的Hadoop版本,并安装hadoop,参考 http://www.cnblogs.com/yong ...

  7. Web前端面试题小集

    一.一个页面上两个div左右铺满整个浏览器,要保证左边的div一直为100px,右边的div跟随浏览器大小变化(比如浏览器为500,右边div为400,浏览器为900,右边div为800),请写出大概 ...

  8. OC中NSLog函数输出格式详解

    OC中NSLog函数输出格式详解 %@ 对象 • %d, %i 整数 • %u 无符整形 • %f 浮点/双字 • %x, %X 二进制整数 • %o 八进制整数 • %zu size_t • %p ...

  9. oc/object-c/ios哪种遍历NSArray/NSDictionary方式快?测试报告

    做app的时候,总免不了要多次遍历数组或者字典.究竟哪种遍历方式比较快呢?我做了如下测试:首先定义测试用宏: ? 1 2 3 4 5 6 7 8 9 #define MULogTimeinterval ...

  10. TEA加密算法java版

    这个算法简单,而且效率高,每次可以操作8个字节的数据,加密解密的KEY为16字节,即包含4个int数据的int型数组,加密轮数应为8的倍数,一般比较常用的轮数为64,32,16,推荐用64轮. 源代码 ...