python - 如何在 PyQt4 中创建 QString?

标签 python user-interface pyqt

>>> 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/

相关文章:

python - Django 中从 sqlite 迁移到 postgresql

python - Pandas - 根据条件复制行

java - 领域模型和用户界面

python - PyQT 表模型数据绑定(bind)

python - 当小部件失去焦点时如何拦截

python - 用rocm导入tensorflow时出现"Failed to load the native TensorFlow runtime."错误

python - “int”对象不可调用

java - 学习 GUI - setContentPane() 方法

angularjs - 使用 AngularJS UI Bootstrap 分页时返回正确的页面

python - 向 QTreeWidgetItem 切换复选框发出信号