Saving a QPixmap Object problem
Hi, i want to save a QPixmap object as File.png...
Code:
format
=QtCore.
QString("png") #to QString. intitialPath
=QtCore.
QDir.
currentPath()+"/snapshot"+str
(self.
counter)+"."+format
fileName
=QtGui.
QFileDialog.
getSaveFileName(self,
"Save As", intitialPath,
"PNG Files (*.png);;All Files (*.*)" ) if not fileName.isEmpty():
self.originalPixamp.save(fileName, format.toAscii())
self.counter += 1
self.counter is just for formatting the snapshot name.
Error:
Quote:
self.originalPixamp.save(fileName, QtCore.QString(format.toAscii()))
TypeError: argument 2 of QPixmap.save() has an invalid type
However, in C++ i used it the same way and it works ?!
I'm using PyQt4
Thanks in advance.
Re: Saving a QPixmap Object problem
toAscii() returns a QByteArray. Use "PNG" or toAscii().constData() instead.
Re: Saving a QPixmap Object problem
Quote:
toAscii() returns a QByteArray. Use "PNG" or toAscii().constData() instead.
Thanks,
Code:
self.originalPixmap.save(fileName, format.toAscii().data())
works fine.
Re: Saving a QPixmap Object problem
Why not
Code:
self.originalPixmap.save(filename, "PNG")
?
Re: Saving a QPixmap Object problem
Actually any 'd have worked, but the problem was about Spelling !
Wrong variable_name:
Code:
self.originalPixamp
It should be: self.originalPixmap,
Thanks again.