我通过FTP接收二进制文件并将其存储为(Pdb) self.events[x]
<event.Event object at 0x7fce0b43c590>
(Pdb) type(self.events[x])
<class 'event.Event'>
(Pdb) self.events[x].time
<type 'datetime.datetime'>
(Pdb) type(self.events[x].time)
<type 'type'>
(Pdb) self.events[x].__dict__
{'resource': None, 'constraint_time': <type 'datetime.time'>, 'constraint': None, 'shift': None, '_driver': <neo4j.v1.direct.DirectDriver object at 0x7fce0b43c910>, 'cust_in_car': 0, 'linked': None, 'epoch': 1514775600000, 'place': None, 'user': None, 'time': <type 'datetime.datetime'>, 'action': 'ShiftStart', 'neo_id': 2339, 'id': 'e828acca-5d32-42e1-967d-c044c775ae47', 'previous': None}
(Pdb) self.events[x].time.__dict__
dict_proxy({'__str__': <slot wrapper '__str__' of 'datetime.datetime' objects>, '__getattribute__': <slot wrapper '__getattribute__' of 'datetime.datetime' objects>, '__radd__': <slot wrapper '__radd__' of 'datetime.datetime' objects>, 'utctimetuple': <method 'utctimetuple' of 'datetime.datetime' objects>, 'second': <attribute 'second' of 'datetime.datetime' objects>, 'utcnow': <method 'utcnow' of 'datetime.datetime' objects>, '__lt__': <slot wrapper '__lt__' of 'datetime.datetime' objects>, '__sub__': <slot wrapper '__sub__' of 'datetime.datetime' objects>, '__new__': <built-in method __new__ of type object at 0x939c20>, 'min': datetime.datetime(1, 1, 1, 0, 0), 'dst': <method 'dst' of 'datetime.datetime' objects>, 'astimezone': <method 'astimezone' of 'datetime.datetime' objects>, 'strptime': <method 'strptime' of 'datetime.datetime' objects>, 'utcfromtimestamp': <method 'utcfromtimestamp' of 'datetime.datetime' objects>, 'combine': <method 'combine' of 'datetime.datetime' objects>, 'timetuple': <method 'timetuple' of 'datetime.datetime' objects>, 'max': datetime.datetime(9999, 12, 31, 23, 59, 59, 999999), 'tzinfo': <attribute 'tzinfo' of 'datetime.datetime' objects>, '__doc__': 'datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])\n\nThe year, month and day arguments are required. tzinfo may be None, or an\ninstance of a tzinfo subclass. The remaining arguments may be ints or longs.\n', 'tzname': <method 'tzname' of 'datetime.datetime' objects>, 'isoformat': <method 'isoformat' of 'datetime.datetime' objects>, '__ne__': <slot wrapper '__ne__' of 'datetime.datetime' objects>, '__reduce__': <method '__reduce__' of 'datetime.datetime' objects>, 'replace': <method 'replace' of 'datetime.datetime' objects>, 'utcoffset': <method 'utcoffset' of 'datetime.datetime' objects>, 'microsecond': <attribute 'microsecond' of 'datetime.datetime' objects>, '__add__': <slot wrapper '__add__' of 'datetime.datetime' objects>, '__gt__': <slot wrapper '__gt__' of 'datetime.datetime' objects>, 'date': <method 'date' of 'datetime.datetime' objects>, 'now': <method 'now' of 'datetime.datetime' objects>, '__eq__': <slot wrapper '__eq__' of 'datetime.datetime' objects>, 'minute': <attribute 'minute' of 'datetime.datetime' objects>, 'ctime': <method 'ctime' of 'datetime.datetime' objects>, 'hour': <attribute 'hour' of 'datetime.datetime' objects>, 'fromtimestamp': <method 'fromtimestamp' of 'datetime.datetime' objects>, '__le__': <slot wrapper '__le__' of 'datetime.datetime' objects>, '__repr__': <slot wrapper '__repr__' of 'datetime.datetime' objects>, 'time': <method 'time' of 'datetime.datetime' objects>, '__hash__': <slot wrapper '__hash__' of 'datetime.datetime' objects>, '__rsub__': <slot wrapper '__rsub__' of 'datetime.datetime' objects>, 'timetz': <method 'timetz' of 'datetime.datetime' objects>, 'resolution': datetime.timedelta(0, 0, 1), '__ge__': <slot wrapper '__ge__' of 'datetime.datetime' objects>})
。原始图像是BMP,但要通过FTP我将其转换为QString
。我能够成功接收这个二进制文件,但我无法转换回QPixmap
或某种格式来显示该图像。
有没有人有任何建议?
答案 0 :(得分:1)
1)使用 QString :: toLatin1(),QString :: toLocal8Bit()将QString转换为QByteArray数据。认为工作只是方法之一
2)用
读取QByteArraybool QPixmap::loadFromData(const QByteArray & data, ...
第一点的功能可能是将数据编码为另一种(文本)编码。然后尝试将QChar *从QString :: data转换为QByteArray。或者将QChar写入文件并从文件中读取QPixmap。