gpt4 book ai didi

python - 如何在 PyQt4 中创建 QString?

转载 作者:太空狗 更新时间:2023-10-29 17:22:10 25 4
gpt4 key购买 nike

>>> from PyQt4 import QtCore
>>> str = QtCore.QString('Hello')
AttributeError: 'module' object has no attribute 'QString'

>>> QtCore.QString._init_(self)
AttributeError: 'module' object has no attribute 'QString'

是的,我读过QString Class Reference

为什么我不能按照文档中的说明从 QtCore 导入 QString

最佳答案

在 Python 3 中,QString 默认自动映射到原生 Python 字符串:

The QString class is implemented as a mapped type that is automatically converted to and from a Python string. In addition a None is converted to a null QString. However, a null QString is converted to an empty Python string (and not None). (This is because Qt often returns a null QString when it should probably return an empty QString.)

The QChar and QStringRef classes are implemented as mapped types that are automatically converted to and from Python strings.

The QStringList class is implemented as a mapped type that is automatically converted to and from Python lists of strings.

The QLatin1Char, QLatin1String and QStringMatcher classes are not implemented.

http://pyqt.sourceforge.net/Docs/PyQt4/qstring.html

关于python - 如何在 PyQt4 中创建 QString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1400858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com