TWAIN DLL that spawns a thread that creates a GUI works on Qt 4.8 died on Qt 5.1.1
-
I’m trying to understand how Qt 4.8 changed – maybe in terms of threading.
I created a DLL for a TWAIN compliant app. This DLL is controlled by an application which is the main thread (it is not a Qt application) . This DLL then spawns a thread and in that thread creates and displays a GUI.
This model structure seemed to work without issue in Qt 4.8.4. Having migrated to Qt 5.1.1 the DLL builds and runs but there are no QDialog messages that are being processed – the GUI has no controls working - seems dead, just displays.
First question is: Is this model/structure possible in Qt 5? Was there changes that would affect this from working as it did in Qt 4.8?
Second question: Is there a preferred way of doing this? This structure is for creating a TWAIN data source. Anyone having any mileage with writing TWAIN compliant apps please chime in.
Thanks in advance
-
Hi,
GUI-related objects in Qt were never supported outside of the main thread. I'm surprised that you say it worked in Qt 4.8; I think you got very lucky, because it is undefined behaviour.
Qt 5 came with a massive restructuring of the GUI rendering engines, which is probably why the 2 versions produced different (undefined) behaviours.
I think your best bet is to stick with Qt 4.
P.S. Did you create a QApplication in your DLL? It's needed to create a QDialog, but it's supposed to complain if you create it outside the main thread.
-
[quote author="JKSH" date="1384915837"]Hi,
GUI-related objects in Qt were never supported outside of the main thread. I'm surprised that you say it worked in Qt 4.8; I think you got very lucky, because it is undefined behaviour.
Qt 5 came with a massive restructuring of the GUI rendering engines, which is probably why the 2 versions produced different (undefined) behaviours.
I think your best bet is to stick with Qt 4.
P.S. Did you create a QApplication in your DLL? It's needed to create a QDialog, but it's supposed to complain if you create it outside the main thread.[/quote]
QApplication is created in the run method of the thread that is spawned from the DSM (TWAIN data source manager). It worked fine in Qt 4.8 - really. It didn't complain
So the fact that I COULD actually create a UI via QApplication in Qt 4.8 you're calling undefined. Regardless, the massive restructuring of the GUI module referred to may be a contributor to the issue that I am seeing.
Thanks