This won't work in a Qt worker thread.
From
http://doc.qt.io/qt-5/thread-basics.html[
^]:
Quote:
As mentioned, each program has one thread when it is started. This thread is called the "main thread" (also known as the "GUI thread" in Qt applications). The Qt GUI must run in this thread. All widgets and several related classes, for example QPixmap, don't work in secondary threads. A secondary thread is commonly referred to as a "worker thread" because it is used to offload processing work from the main thread.
You must move the GUI related operations to the main thread and perform only the time consuming operations inside the worker thread. Especially things like asking the user to select a file should be performed before starting the worker thread. In your case I would also open the file in the main thread and pass the file handle to the worker thread. But note that there must be some kind of synchronization or locking when shared objects may be used at the same time by multiple threads.