set application name in pyside

喜欢而已 提交于 2019-12-02 07:20:53

With Qt5, you can set the applicationDisplayName, which is separate from the main title-bar text.

To show the modification state in the title-bar, you would do this:

    QtWidget.qApp.setApplicationDisplayName('Test')
    ...
    window.setWindowFilePath('/path/to/file.txt')
    window.setWindowModified(True)

and the title-bar would look like this: file.txt* - Test

Alternatively, you can get a little more control of the title-bar text by using a special placeholder when setting the window title:

    window.setWindowTitle('/path/to/file.txt[*]')
    window.setWindowModified(True)

and the title-bar would look like this: /path/to/file.txt* - Test

EDIT:

If you're using Qt4, there will no be applicationDisplayName, so you could try this, instead:

    QtGui.qApp.setApplicationName('Test')
    ...
    window.setWindowTitle(
        '/path/to/file.txt[*] - %s' % QtGui.qApp.applicationName())
    window.setWindowModified(True)

and the title-bar should look like this: /path/to/file.txt* - Test

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!