OSX - handling QEvent::FileOpen
-
In my app, I want to check to see if the user wants to open a file via Finder (using QEvent::FileOpen). If hey haven't, then I want to show a file dialog to ask them for one. But I need to run exec() for events to start flowing. Is there an event that happens after QEvent::FileOpen, that I can use to know that a QEvent::FileOpen is not coming? I'd rather not use a timer. Thanks.
-
Hi,
The event will only happen if e.g. the user drops the file on your application icon. Since this should happen very early in the process, you could set a flag and check it in a slot called using a QTimer::singleShot with 0 as timeout value. This should let the event loop spin enough so that you can handle the FileOpen event. Note that I haven't tried that
Hope it helps
-
Thanks, that seems to work. Do we all think this can be relied upon?
-
I take that back. If I put in a non-zero timeout, it works. Zero does not. Currently I've got 100 msec.
-
Then the event get's a bit later through than I thought. Anyway, did you check if that value is also valid when your computer is under load ?
-
I guess I'm going to have to.