How to Create QSplitter in PyQt5

In this article i want to show you How to Create QSplitter in PyQt5. the QSplitter is an organizer class widget in PyQt5 , which provides a way to insert child widgets which can then be given varying amounts of space. The amount of space allowed is adjusted by the user using a handle on the Splitter. The widget is commonly seen in File Managers and Web Browsers where the main content may also need to share space with a sidepanel such as a tree view or bookmark list.

 

What is QSplitter in PyQt5 ?

PyQt5 QSplitter is graphical user interface (GUI) widget provided by the PyQt5 library. it allows the user to resize and adjust the size of two or more child widgets by dragging  separator between them. QSplitter widget is commonly used as a user interface control for adjusting the size and layout of different areas of the GUI.

PyQt5 QSplitter widget is typically used in conjunction with other layout managers to create flexible and resizable user interfaces. child widgets can be added to the splitter using addWidget() method and the orientation of the splitter can be set to either horizontal or vertical using the setOrientation() method.

also to its basic functionality PyQt5 QSplitter widget provides several properties and signals that can be used to customize its behavior and respond to user interaction. for example sizes() property returns the current size of each child widget in the splitter, and splitterMoved() signal is emitted whenever user moves the separator to new position.

So we can say that PyQt5 QSplitter is useful widget for creating flexible and resizable user interfaces with multiple areas that can be adjusted by the user.

 

 

Also you can read more Python GUI articles in the below links

 

 

 

First we need some imports

 

 

 

After that we are going to create our main Window class that extends from QWidget. and in the constructor of the class we need to add some requirements of the window like set window title, window icon and window geometry.

 

 

 

In here we have created the QHBoxLayout and QFrame object.

 

 

Also every PyQt5 application must create an application object. The sys.argv parameter is a list of arguments from a command line.

 

 

Finally, we enter the mainloop of the application. The event handling starts from this point. The mainloop receives events from the window system and dispatches them to the application widgets.

 

 

 

Complete source code for How To Create PyQt5 QSplitter With Example

 

 

 

Run complete and this will be the result

How to Create QSplitter in PyQt5
How to Create QSplitter in PyQt5

Subscribe and Get Free Video Courses & Articles in your Email

 

Leave a Comment

Share via
Copy link
Powered by Social Snap
×