Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    2
    4
    352
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Andriy last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • A
          Andriy last edited by

          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!

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by SGaist

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post