[Interest] New window in Qt makes the application activate

Rutledge Shawn Shawn.Rutledge at digia.com
Mon Feb 3 07:48:38 CET 2014

On 31 Jan 2014, at 5:49 PM, John Weeks wrote:

> Thanks for your comments, Konrad.
> Part of my question is driven by the fact that our currently-shipping non-Qt version puts up windows while it's not the active application and this does not make the application activate. We run on both Macintosh and Windows. So the fact that Qt applications do this makes me believe that this is a Qt thing. Since that is the case, surely there's a Qt way to avoid doing something that the underlying OS isn't doing.
>> Why open windows at all if you do not intend to actually show the customer anything until you are done?
> Have you worked with scientists? :) Our customers may run a process that creates literally hundreds of graphs, each in a window, by running an automated process.
> Our customers can write code in our internal language to do very lengthy computations analyzing their data. Part of that might include creating a graph (in a window!) showing the result of some part of the analysis, or of one of many data sets. Being able to see that graph come up allows them to monitor the progress of the analysis; having it come up while the application is not the active application allows them to compose e-mail, browse the web, etc., during an analysis that might take many minutes or even hours or days.
> So, no, it wouldn't work to make the windows minimized.
> At the end of the process they want a collection of graphs that will most likely then wind up as the basis for a report or a published paper.
> And, again, Windows and Mac OS X aren't doing this- why does Qt do it?

I suspect that for some reason QWindow::requestActivate() is getting called; you can set a breakpoint there and look at the backtrace to find out why.  But I tried that myself, using code like this

int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;
    MainWindow w2;
    QTimer t;
    t.singleShot(5000, &w2, SLOT(show()));
    return a.exec();

and I don't see the problem, at least not on OSX.  After the first window appears, I can bring another application into the foreground, then after 5 seconds the second window will show up in the background without activating the application.  Even if w2 is a QDialog rather than a QMainWindow it still doesn't interrupt.

More information about the Interest mailing list