<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw" -->

---
title: Fix QImage NumPy Crash in PyQt6 PySide6 Multithreaded...
description: Passing NumPy arrays directly to QImage in multithreaded PyQt6 or PySide6 applications causes crashes because QImage references the NumPy array's memory buffer...
canonical: https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Fix QImage NumPy Crash in PyQt6 PySide6 Multithreaded Applications | daily.dev
og:description: Passing NumPy arrays directly to QImage in multithreaded PyQt6 or PySide6 applications causes crashes because QImage references the NumPy array's memory buffer...
og:url: https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw
og:image: https://api.daily.dev/og/posts/w2SEqHOcw.png
og:image:alt: Fix QImage NumPy Crash in PyQt6 PySide6 Multithreaded Applications
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Fix QImage NumPy Crash in PyQt6 PySide6 Multithreaded Applications

**[Planet Python](https://daily.dev/sources/planetpython)** · 6 min read · 0 upvotes · 0 comments

## Summary

Passing NumPy arrays directly to QImage in multithreaded PyQt6 or PySide6 applications causes crashes because QImage references the NumPy array's memory buffer instead of copying it, so if the array changes or goes out of scope while the GUI thread paints it, the memory becomes invalid. The fix is calling .copy() on the QImage immediately after creation and before emitting it across a signal, ensuring the QImage owns its own memory. GUI updates must always happen on the main thread via signals and slots rather than direct calls from worker threads. A complete QRunnable/QThreadPool example demonstrates safely streaming simulated video frames to a QLabel without crashes during resize or scroll.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.pythonguis.com/faq/crashing-in-qrunner-threads-with-numpy>

## Questions this post answers

### Why does my PyQt6 app crash when displaying a QImage created from a NumPy array in a worker thread?

The crash happens because QImage does not copy the NumPy array's data by default, it just references the same memory buffer. If the array is modified or freed while the GUI thread is still painting from it, the memory becomes invalid, causing a segfault or silent crash, especially during rapid resizing or scrolling.

_daily.dev surfaces practical fixes like this for developers debugging multithreaded Qt and NumPy integration issues._

### How do I safely pass a QImage created from a NumPy array between threads in PyQt6 or PySide6?

Call .copy() on the QImage immediately after creating it in the worker thread, before emitting it through a signal, so it owns its own memory buffer independent of the original NumPy array. Then connect that signal to a slot on the main thread that performs the actual setPixmap() call, since all GUI updates must happen on the main thread.

_Developers building live video or streaming GUIs with PyQt6 track threading fixes like this on daily.dev._

### Can I call setPixmap() directly from a worker thread in a PyQt6 application?

No, calling GUI methods like label.setPixmap() directly from a worker thread is undefined behavior in Qt and will eventually crash the application. All GUI updates must happen on the main thread; the correct pattern is to emit a signal from the worker carrying the processed image and connect it to a slot on the main thread that performs the update.

_daily.dev helps Qt developers keep up with threading patterns before they cause production crashes._

## Similar posts on daily.dev

- [How to Pass Arguments to QRunnable Worker Threads in PyQt6](https://daily.dev/posts/how-to-pass-arguments-to-qrunnable-worker-threads-in-pyqt6-3teggi4li) · Planet Python · 0 upvotes · 0 comments
- [Wayland Wars, a Custom File Picker, and Non-Blocking Threads: Building a Responsive Qt App](https://daily.dev/posts/wayland-wars-a-custom-file-picker-and-non-blocking-threads-building-a-responsive-qt-app-pcji3yhzg) · Medium · 0 upvotes · 0 comments
- [Qt for Python Release: 6.12 is here\!](https://daily.dev/posts/qt-for-python-release-6-12-is-here--b6vjnokga) · Qt · 2 upvotes · 1 comments
- [How to Dynamically Add Rows of Widgets in PyQt6 with QGridLayout](https://daily.dev/posts/how-to-dynamically-add-rows-of-widgets-in-pyqt6-with-qgridlayout-j2fgwv51s) · Planet Python · 1 upvotes · 0 comments
- [PyQt Layouts: Create Professional-Looking GUI Applications Quiz – Real Python](https://daily.dev/posts/pyqt-layouts-create-professional-looking-gui-applications-quiz-real-python-feozzhaha) · Real Python · 0 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#numpy](https://daily.dev/tags/numpy)

[View this post on daily.dev](https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Fix QImage NumPy Crash in PyQt6 PySide6 Multithreaded Applications","url":"https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw"},"datePublished":"2026-09-09T07:51:34.825Z","dateModified":"2026-09-14T09:00:36.137Z","description":"Passing NumPy arrays directly to QImage in multithreaded PyQt6 or PySide6 applications causes crashes because QImage references the NumPy array's memory buffer...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0bd3d5ba67a1fb765df397002d0ff1ec?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0bd3d5ba67a1fb765df397002d0ff1ec?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet Python","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet Python","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/eac3cc584cb043b5a242d13752bd3d0c","url":"https://daily.dev/sources/planetpython"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,numpy","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet Python","item":"https://daily.dev/sources/planetpython"},{"@type":"ListItem","position":3,"name":"Fix QImage NumPy Crash in PyQt6 PySide6 Multithreaded Applications"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/fix-qimage-numpy-crash-in-pyqt6-pyside6-multithreaded-applications-w2seqhocw#faq","mainEntity":[{"@type":"Question","name":"Why does my PyQt6 app crash when displaying a QImage created from a NumPy array in a worker thread?","acceptedAnswer":{"@type":"Answer","text":"The crash happens because QImage does not copy the NumPy array's data by default, it just references the same memory buffer. If the array is modified or freed while the GUI thread is still painting from it, the memory becomes invalid, causing a segfault or silent crash, especially during rapid resizing or scrolling. daily.dev surfaces practical fixes like this for developers debugging multithreaded Qt and NumPy integration issues."}},{"@type":"Question","name":"How do I safely pass a QImage created from a NumPy array between threads in PyQt6 or PySide6?","acceptedAnswer":{"@type":"Answer","text":"Call .copy() on the QImage immediately after creating it in the worker thread, before emitting it through a signal, so it owns its own memory buffer independent of the original NumPy array. Then connect that signal to a slot on the main thread that performs the actual setPixmap() call, since all GUI updates must happen on the main thread. Developers building live video or streaming GUIs with PyQt6 track threading fixes like this on daily.dev."}},{"@type":"Question","name":"Can I call setPixmap() directly from a worker thread in a PyQt6 application?","acceptedAnswer":{"@type":"Answer","text":"No, calling GUI methods like label.setPixmap() directly from a worker thread is undefined behavior in Qt and will eventually crash the application. All GUI updates must happen on the main thread; the correct pattern is to emit a signal from the worker carrying the processed image and connect it to a slot on the main thread that performs the update. daily.dev helps Qt developers keep up with threading patterns before they cause production crashes."}}]}
```

