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. The WindowDoesNotAcceptFocus flag is making me thirsty!!!!!!!

The WindowDoesNotAcceptFocus flag is making me thirsty!!!!!!!

Scheduled Pinned Locked Moved Unsolved General and Desktop
17 Posts 12 Posters 6.3k Views 4 Watching
  • 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.
  • L Offline
    L Offline
    lordk
    wrote on last edited by
    #8

    Hi, this bug is still not fixed in Windows 10, right? I´m coding a custom keyboard and I having trouble with the buttons stealing the focus from text inputs like word, notepad, etc.

    Regards.

    mrjjM 1 Reply Last reply
    0
    • L lordk

      Hi, this bug is still not fixed in Windows 10, right? I´m coding a custom keyboard and I having trouble with the buttons stealing the focus from text inputs like word, notepad, etc.

      Regards.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #9

      @lordk
      Hi
      Yes its still flagged as unresolved.

      L 1 Reply Last reply
      0
      • mrjjM mrjj

        @lordk
        Hi
        Yes its still flagged as unresolved.

        L Offline
        L Offline
        lordk
        wrote on last edited by lordk
        #10
        This post is deleted!
        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mario_Moysen
          wrote on last edited by
          #11

          At least for me is working very fine with PySide6 just by setting up into the MainWindow init function like so: self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WindowDoesNotAcceptFocus)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            deblin
            wrote on last edited by
            #12

            Hi ich versuche das gleiche verhalten unter wayland zu erhalten, aber bekomme es nicht hin :(

            from PyQt6.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget
            from PyQt6.QtCore import Qt
            from PyQt6 import QtCore
            class TestWidget(QWidget):
              def __init__(self):
                  super().__init__()
                  self.setWindowFlags(Qt.WindowType.NoDropShadowWindowHint | 
                                      Qt.WindowType.FramelessWindowHint | 
                                      Qt.WindowType.WindowStaysOnTopHint | 
                                      Qt.WindowType.WindowDoesNotAcceptFocus | 
                                      Qt.WindowType.BypassWindowManagerHint)
                  self.initUI()
            
            
              def initUI(self):
                  self.button = QPushButton('Button', self)
                  self.button.clicked.connect(self.on_button_click)
                  layout = QVBoxLayout()
                  layout.addWidget(self.button)
                  self.setLayout(layout)
            
            #        self.setAttribute(Qt.WidgetAttribute.WA_ForceDisabled, True)
                  self.show()
            
              def on_button_click(self):
                  print('Button clicked')
            
            if __name__ == '__main__':
              app = QApplication([])
              w = TestWidget()
              app.exec()
            

            ich hab es mal versucht wie im letzten kommentar angegeben nach oben zu verschieben aber no luck :( gibt es schon eine loesung dafuer ?

            jsulmJ JonBJ 2 Replies Last reply
            0
            • D deblin

              Hi ich versuche das gleiche verhalten unter wayland zu erhalten, aber bekomme es nicht hin :(

              from PyQt6.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget
              from PyQt6.QtCore import Qt
              from PyQt6 import QtCore
              class TestWidget(QWidget):
                def __init__(self):
                    super().__init__()
                    self.setWindowFlags(Qt.WindowType.NoDropShadowWindowHint | 
                                        Qt.WindowType.FramelessWindowHint | 
                                        Qt.WindowType.WindowStaysOnTopHint | 
                                        Qt.WindowType.WindowDoesNotAcceptFocus | 
                                        Qt.WindowType.BypassWindowManagerHint)
                    self.initUI()
              
              
                def initUI(self):
                    self.button = QPushButton('Button', self)
                    self.button.clicked.connect(self.on_button_click)
                    layout = QVBoxLayout()
                    layout.addWidget(self.button)
                    self.setLayout(layout)
              
              #        self.setAttribute(Qt.WidgetAttribute.WA_ForceDisabled, True)
                    self.show()
              
                def on_button_click(self):
                    print('Button clicked')
              
              if __name__ == '__main__':
                app = QApplication([])
                w = TestWidget()
                app.exec()
              

              ich hab es mal versucht wie im letzten kommentar angegeben nach oben zu verschieben aber no luck :( gibt es schon eine loesung dafuer ?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #13

              @deblin Hi! Es gibt Forum in Deutscher Sprache hier: https://forum.qt.io/category/28/german

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D deblin

                Hi ich versuche das gleiche verhalten unter wayland zu erhalten, aber bekomme es nicht hin :(

                from PyQt6.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget
                from PyQt6.QtCore import Qt
                from PyQt6 import QtCore
                class TestWidget(QWidget):
                  def __init__(self):
                      super().__init__()
                      self.setWindowFlags(Qt.WindowType.NoDropShadowWindowHint | 
                                          Qt.WindowType.FramelessWindowHint | 
                                          Qt.WindowType.WindowStaysOnTopHint | 
                                          Qt.WindowType.WindowDoesNotAcceptFocus | 
                                          Qt.WindowType.BypassWindowManagerHint)
                      self.initUI()
                
                
                  def initUI(self):
                      self.button = QPushButton('Button', self)
                      self.button.clicked.connect(self.on_button_click)
                      layout = QVBoxLayout()
                      layout.addWidget(self.button)
                      self.setLayout(layout)
                
                #        self.setAttribute(Qt.WidgetAttribute.WA_ForceDisabled, True)
                      self.show()
                
                  def on_button_click(self):
                      print('Button clicked')
                
                if __name__ == '__main__':
                  app = QApplication([])
                  w = TestWidget()
                  app.exec()
                

                ich hab es mal versucht wie im letzten kommentar angegeben nach oben zu verschieben aber no luck :( gibt es schon eine loesung dafuer ?

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #14

                @deblin said in The WindowDoesNotAcceptFocus flag is making me thirsty!!!!!!!:

                unter wayland zu erhalten

                There are several features of a windowing system that Wayland does not allow/support. For example, you cannot move a window to a particular position. Maybe it does not accept this flag? If it works under Xorg but not under Wayland this is probably the case?

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deblin
                  wrote on last edited by
                  #15

                  Oh I am sorry the hole website is in german and i forgot about it xD

                  To be a little more precise it is wayland gnome with kompositor mutter.

                  i tried it now in native language

                  #include <QApplication>
                  #include <QPushButton>
                  #include <QWidget>
                  
                  int main(int argc, char **argv) {
                      QApplication app(argc, argv);
                  
                      QWidget window;
                      window.setWindowFlags(Qt::WindowDoesNotAcceptFocus);
                  
                      QPushButton button("Click me!", &window);
                      QObject::connect(&button, &QPushButton::clicked, [&]() {
                          button.setText("You clicked me!");
                      });
                  
                      window.show();
                      return app.exec();
                  }
                  but onclick it gets focus :( I wrote a virtuel keyboard that runs fine under x11 but wayland always gives it a focus, therefore i cant use it ....
                  
                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    deblin
                    wrote on last edited by
                    #16

                    i didnt find a soloution only a work-around :(

                    created a gnomeshell plugin to bounce back focus

                    {
                        "shell-version": ["43.6"],
                        "uuid": "myextension@example.com",
                        "name": "My Extension",
                        "description": "Example Gnome Shell Extension"
                    }
                    
                    const Main = imports.ui.main;
                    const Shell = imports.gi.Shell;
                    
                    let focusChangedId;
                    let previousWindow;
                    
                    function enable() {
                        focusChangedId = global.display.connect('notify::focus-window', () => {
                            const focusedWindow = global.display.focus_window;
                            if (focusedWindow) {
                                // Prüfen Sie, ob das fokussierte Fenster das ist, das Sie ignorieren möchten
                                if (focusedWindow.get_title() === 'ignorier') {
                                    // Wenn das der Fall ist, setzen Sie den Fokus zurück auf das vorherige Fenster
                                    if (previousWindow) {
                                        Main.activateWindow(previousWindow);
                                    }
                                } else {
                                    // Wenn das nicht der Fall ist, aktualisieren Sie das vorherige Fenster
                                    previousWindow = focusedWindow;
                                }
                            }
                        });
                    }
                    
                    function disable() {
                        if (focusChangedId) {
                            global.display.disconnect(focusChangedId);
                            focusChangedId = null;
                            previousWindow = null;
                        }
                    }
                    
                    
                    

                    and switched it on with the python prog

                    import subprocess
                    
                    def enable_extension(extension_id):
                        subprocess.run(['gnome-extensions', 'enable', extension_id])
                    
                    def disable_extension(extension_id):
                        subprocess.run(['gnome-extensions', 'disable', extension_id])
                    
                    

                    but this creates other issues :( so I am back too X11 good luck to the next one! 2017 was the first post to this is. I try it in another 5 years ....

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      Yoho
                      wrote on last edited by
                      #17

                      I've encountered a similar problem. In my case, the widget continually activates and gains focus while being resized. I've set the following properties for the widget:

                      setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
                      setAttribute(Qt::WA_ShowWithoutActivating);
                      

                      This issue seems to occur only on Windows, and it doesn't happen before we upgrade to 5.15; I haven't experienced it on MacOS. My solution was to add Qt::BypassWindowManagerHint to the widget, and the widget won't get activated and focused anymore.

                      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