如何在 PyQt4 中创建 QString? [英] How to create QString in PyQt4?

查看:64
本文介绍了如何在 PyQt4 中创建 QString?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<预><代码>>>>从 PyQt4 导入 QtCore>>>str = QtCore.QString('你好')AttributeError: 'module' 对象没有属性 'QString'>>>QtCore.QString._init_(self)AttributeError: 'module' 对象没有属性 'QString'

是的,我已经阅读了 QString 类参考

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

解决方案

In [1]: from PyQt4 import QtCore在 [2]: s = QtCore.QString('foo')在 [3] 中:s出[3]:PyQt4.QtCore.QString(u'foo')

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

Yes, I've read QString Class Reference

Why can't I import QString from QtCore, as specified in the docs ?

解决方案

In [1]: from PyQt4 import QtCore
In [2]: s = QtCore.QString('foo')
In [3]: s
Out[3]: PyQt4.QtCore.QString(u'foo')

这篇关于如何在 PyQt4 中创建 QString?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆