【问题标题】:PyQt: Right to left controlsPyQt:从右到左的控件
【发布时间】:2011-04-02 06:43:03
【问题描述】:

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

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

【问题讨论】:

    标签: user-interface pyqt4 qt-designer


    【解决方案1】:

    很简单:

    # 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)
    

    【讨论】:

    • 这给了我TypeError: addWidget() takes no keyword arguments
    【解决方案2】:

    看看QDockWidget。这个example 也可能有用。

    【讨论】:

    • 我不想停靠我的控件。我只需要从右边对齐它们。
    • 自 2016 年起链接处于离线状态
    猜你喜欢
    • 2017-04-28
    • 2010-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 2022-01-13
    • 1970-01-01
    • 2017-07-22
    相关资源
    最近更新 更多