PYQT5 every day must learn the Qsplitter to achieve window separation

Source: Internet
Author: User
This article mainly introduced the PYQT5 every day must learn the window separates, has the certain reference value, the interest small partner may refer to

Qsplitter enables the user to control the size of the sub-panel by dragging the boundaries of the sub-panel. In our case, we used two qsplitter to separate three qframe controls from each other.

#!/usr/bin/python3#-*-coding:utf-8-*-"" "PYQT5 Tutorial This example shows how to use Qsplitter parts. Author: My World You've been to the blog: Http://blog.csdn.net/weiaitaowang Last edited: August 4, 2016 "" "Import sysfrom pyqt5.qtwidgets Import ( Qapplication, Qwidget, Qhboxlayout, Qframe, Qsplitter) from Pyqt5.qtcore import Qtclass Example (qwidget): def __init__ (SE LF): Super (). __init__ () Self.initui () def initui (self): Hbox = Qhboxlayout (self) topleft = Qframe  Pleft.setframeshape (qframe.styledpanel) TopRight = Qframe (self) topright.setframeshape (qframe.styledpanel) Bottom = Qframe (self) bottom.setframeshape (qframe.styledpanel) splitter1 = Qsplitter (qt.horizontal) splitter1.addwidget (TopLeft) Splitter1.addwidget (topright) Splitter2 = Qsplitter (qt.vertical) splitter2.addwidget (splitter1) spli Tter2.addwidget (bottom) hbox.addwidget (splitter2) self.setlayout (Hbox) self.setgeometry (+, +) se Lf.setwindowtitle (' window delimited ') self.show () if __name__ = = ' __main__ ': app = Qapplication (SYS.ARGV) ex = Example () sys.exit (App.exec_ ()) 

In our example, we used three frame parts and two qsplitter. Note that the qsplitter boundaries of some topics may not be visible.

TopLeft = Qframe (self)
Topleft.setframeshape (Qframe.styledpanel)

We add Styledpanel styles to the Qframe control to make the bounds between the qframe controls more pronounced.

Splitter1 = Qsplitter (qt.horizontal)
Splitter1.addwidget (TopLeft)
Splitter1.addwidget (TopRight)

We created a Qsplitter control and added two qframe in.

Splitter2 = Qsplitter (qt.vertical)
Splitter2.addwidget (Splitter1)

We can also add a splitter to another splitter widget. We can also add one qsplitter to another qsplitter control.

After the program executes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.