Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Qt designer for window layout in Python GUI

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use Qt designers for window layout in Python GUI". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Qt designers for window layout in Python GUI".

In Qt, we can drag a layout widget directly from the widget bar on the left to the GUI window, and then drag the specific widget into the layout widget, so that the widget will automatically layout accordingly.

Vertical layout

Drag "Vertical Layout" from the "Layouts" bar on the left panel to the GUI window, set the layout size, and then drag 3 "Push Button" in the "Buttons" bar to the set size "Vertical Layout":

Horizontal layout

Drag "Horizontal Layout" from the "Layouts" bar on the left panel to the GUI window, set the layout size, and then drag 3 "Push Button" in the "Buttons" bar to the set size "Horizontal Layout":

Another way of horizontal layout and vertical layout

Above we use to set up a layout widget, and then put the widget into the layout widget layout. In addition, we can first place the widget in the GUI window, frame the parts that need to be laid out, and then use the horizontal layout and Vertical layout buttons in the toolbar to manage the layout of the widget:

Grid layout

Like vertical and horizontal layouts, grid layouts can use the above two methods to manage the layout of widgets:

Nested layout

In addition to laying out the subassembly, we can also nest the layout in the grid:

Container layout

In addition to using layout controls, we can also use containers for rough layout, as demonstrated by the groupBox container:

Use "Spacer" interval

The widgets we place in the layout widget are all equidistant. If we need to set the distance of one of the widgets a little further, we can use the "Spacer" spacer widget.

There are two types of "Spacer" parts:

Horizontal Spacer: vertical interval

Vertical Spacer: horizontal interval.

The spacer part is in the "Spacer" column of the left widget, so let's demonstrate:

Set the "partner" for the label

A useful basic feature in Pyqt is the "partner" widget. When the user types the shortcut key for the tag, the focus of the cursor appears on the partner of the tag.

For example: we have a user name label and a user name input box, set the user name label and user name input box to "partner", set the user name label text to "user name (& 2)", indicating that the shortcut key for the user name label is Alt+2, if we press the shortcut key Alt+2, then the input character of the cursor will be moved to the user name input box.

In qt designers, the "partner" function, in the Edit partner button on the toolbar:

Thank you for your reading, these are the contents of "how to use Qt designers for window layout in Python GUI". After the study of this article, I believe you have a deeper understanding of how to use Qt designers for window layout in Python GUI, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report