Does QWidgetPrivate::setFocus_sys() behaves correctly on Windows OS according to Microsoft Windows Management Guidelines?



  • On Windows OS QWidgetPrivate::setFocus_sys() use QWindow::requestActivate which calls QWindowsWindow::requestActivateWindow() and here SetForegroundWindow function used, to bring our main window to front(if I understand everything correct). But is this according to Microsoft Windows Management Guidelines ? If you take a look to chapters "Window activation" and "Input focus", they say, that if user busy with something else, do not interrupt him with bringing application on top of another, but this is actually what we do here? Am I correct, or I understand something wrong? Thanks for any answers!


  • Lifetime Qt Champion

    Hi,

    Can you explain your use case ? It's not really clear based on your question.



  • Sory, for not be concreet, I reread my message, and indeed it not clear.

    So here the case I have in my project, but I manage to reproduce it on Qt "mdi" example project with small modification. (Somehow I cannot upload it, so I add a link to my google drive zip archive. Do not afraid to open link).

    To simulate the situation on our project, I creates 100 QMdiSubWindowses, on sturtup with next configurations:

        MdiChild *child = new MdiChild;
        child->setFocusPolicy(Qt::StrongFocus);
        child->setAttribute(Qt::WA_NativeWindow);
    
    
        QMdiSubWindow *subWindow = new QMdiSubWindow();
        subWindow->setAttribute(Qt::WA_NativeWindow);
        subWindow->setFocusPolicy(Qt::StrongFocus);
    
        subWindow->setWidget(child);
        subWindow->setFocusProxy(child);
    
        mdiArea->addSubWindow(subWindow);
    
        subWindow->setWindowState(Qt::WindowMaximized);
    

    And after showing all this MdiSubWindowses one by one after creation, application starts to steal focus from you each time, when windows appear. When I get rid of the line child->setAttribute(Qt::WA_NativeWindow); everything works ok. But I cannot do this on my real project.

    For me it is not clear why this happend, because I think, that we should folow the guidlines in any configuration, for "alien" and "native" windows.

    If I can do something about this, please let me know.

    P.S. I tried to use Qt::WA_ShowWIthoutActivating, but it would not help, as this activation hapend in another place in code.

    Thanks for your answers!


  • Lifetime Qt Champion

    Can you describe what your application does the requires that many native windows ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.