PyQt:从右到左控件

发布于 2024-09-15 10:53:14 字数 229 浏览 4 评论 0原文

我需要所有控件都正确对齐。因此,调整大小时,它们应该随窗口的右上角而不是左上角移动。 在 Visual Studio 中,我只需将任何控件的 Anchor 属性设置为向右和向上。但 PyQt 没有 Anchor 或 Dock 属性。将 layoutDirection 设置为 RightToLeft 没有帮助。

注意:我正在尝试使用 Qt Designer 来学习 PyQt。

I need my all controls to be right aligned. so when resizing they should move with the right upped corner of window instead of left upper.
In visual studio, I simply set the Anchor property of any control to right and up. but PyQt has no Anchor or Dock property. Setting layoutDirection to RightToLeft didn't help.

note: I'm trying to learn PyQt using Qt Designer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独岁月 2024-09-22 10:53:14

这很简单:

# Create a layout
layout = QHBoxLayout()
# create a control
button = QPushButton("button")
# add the button to the layout and align it to the right
layout.addWidget(button, alignment=Qt.AlignRight)

It's quite easy:

# Create a layout
layout = QHBoxLayout()
# create a control
button = QPushButton("button")
# add the button to the layout and align it to the right
layout.addWidget(button, alignment=Qt.AlignRight)
冧九 2024-09-22 10:53:14

看看QDockWidget。这个示例也可能有用。

Take a look at QDockWidget. This example might also be useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文