Reputation: 1338
I am writing a PyQt program which I want to be able to copy to the clipboard. Currently I have the following snippet copy the code (based on this:
def copy_to_clipboard(self):
application=QApplication(sys.argv)
if not self.image.isNull():
application.clipboard().setImage(self.image)
The code is copying the image, but every time it runs, the program crashes. The images aren't insanely huge (about 1000px on a side) and I have copied images much lager than this before (not with Qt).
I am getting the following exit code:
Process finished with exit code -805306369 (0xCFFFFFFF)
What is wrong?
Upvotes: 1
Views: 516
Reputation: 11849
Constructing more than one QApplication
is likely the cause of the problem (you should only have 1 per process). Rather than constructing a new QApplication
, just request a reference to the existing once by using QApplication.instance()
Upvotes: 2