【问题标题】:It is possible to assign it a keyboard shortcut or mnemonic In QLabel?是否可以在 QLabel 中为其分配键盘快捷键或助记符?
【发布时间】:2020-09-13 23:38:57
【问题描述】:

在 PyQt5 中使用 QLabel 时,可以给它一个键盘快捷键或助记符 ...

例如:

通过将文本设置为"E&xit"助记符为x,键盘快捷键为Alt+x.

【问题讨论】:

    标签: python pyqt pyqt5 qlabel


    【解决方案1】:

    我还没有测试过(它似乎只适用于 windows,我在 mac OS 上)但是从 Qt 文档中,您可以使用 setBuddy() 将您的 QLabel 链接到 QlineEdit,例如:

        nameEdit = QtWidgets.QLineEdit()
        nameLabel = QtWidgets.QLabel("&Name")
        nameLabel.setBuddy(nameEdit)
    

    【讨论】:

    • 它只分配给 QLineedit。只是我想单独在 Qlabel 中使用
    猜你喜欢
    • 1970-01-01
    • 2010-10-02
    • 2016-09-20
    • 2012-04-06
    • 2023-03-19
    • 2011-02-13
    • 2015-09-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多