Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does QWidgetPrivate::setFocus_sys() behaves correctly on Windows OS according to Microsoft Windows Management Guidelines?

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 704 Views
  • 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 Offline
    A Offline
    Andriy
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • A Offline
        A Offline
        Andriy
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by SGaist
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved