[Qt-interest] global thread not running until main app starts
Arnold Krille
arnold at arnoldarts.de
Wed Jan 14 08:45:24 CET 2009
On Wednesday 14 January 2009 02:42:12 Paul England wrote:
> How exactly would main() look in that case? What would it return
> instead of app.exec() ?
You would still return the return-value of app.exec(). Only you would create
the threads somewhere inside the dialog-object after the event-loop runs. For
example with a private slot in the dialog and a QTimer::singleShot in dialogs
constructor.
There are some other points in your app that can give your problems:
- You actually don't read the data as soon as its arrived but only when there
is enough data in QIODevice's buffer to read a line (which is terminated by
\n).
- Accessing a variable from multiple threads (especially when writing from
multiple threads) calls for locking. Have a look at QMutex and the like to
learn about that...
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090114/db6a656c/attachment.bin
More information about the Qt-interest-old
mailing list