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.
  • 6thC6 Offline
    6thC6 Offline
    6thC
    wrote on last edited by
    #4

    I don't mind seeing people wanting old bugs sorted and asking for attention on the forums. Being noticed is the only way to get an action.

    To bring balance to the force: One thing to highlight an old bug - another thing entirely to argue drop everything for this. I don't want that. I get new things and new things fixed every release... I don't want brakes applied to everything else because they couldn't get to this.

    Ridiculing Qt for releasing new versions while this is outstanding is a ridiculous concept itself. And you probably know it, you're passionate to see this fixed, we get it. I do advocate voicing the wish to have this looked at again - just not how.

    A 1 Reply Last reply
    0
    • A amonR2

      Lol! a pop-up message telling me that the topic is too old ahah!

      Anyway, so far the bug is getting really old, 4 years soon! Please Qt, fix it!! I face the same issue by using C++ on Windows 8 and Windows 8.1 with Qt 5.9 . What's the point to release Qt 5.10 when the previous version which is even not 1 year old can't run the basics? 0_o

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

      @amonR2 It will not help asking here to fix the bug - this is user forum. You should comment on the bug instead.

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

      1 Reply Last reply
      0
      • A amonR2

        Lol! a pop-up message telling me that the topic is too old ahah!

        Anyway, so far the bug is getting really old, 4 years soon! Please Qt, fix it!! I face the same issue by using C++ on Windows 8 and Windows 8.1 with Qt 5.9 . What's the point to release Qt 5.10 when the previous version which is even not 1 year old can't run the basics? 0_o

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #6

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

        Anyway, so far the bug is getting really old, 4 years soon! Please Qt, fix it!! I face the same issue by using C++ on Windows 8 and Windows 8.1 with Qt 5.9 . What's the point to release Qt 5.10 when the previous version which is even not 1 year old can't run the basics? 0_o

        Since Qt is open source you are welcome to provide the fix.
        If you are not able to do so, i would say be thankful for what you get free of charge.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        2
        • 6thC6 6thC

          I don't mind seeing people wanting old bugs sorted and asking for attention on the forums. Being noticed is the only way to get an action.

          To bring balance to the force: One thing to highlight an old bug - another thing entirely to argue drop everything for this. I don't want that. I get new things and new things fixed every release... I don't want brakes applied to everything else because they couldn't get to this.

          Ridiculing Qt for releasing new versions while this is outstanding is a ridiculous concept itself. And you probably know it, you're passionate to see this fixed, we get it. I do advocate voicing the wish to have this looked at again - just not how.

          A Offline
          A Offline
          amonR2
          wrote on last edited by
          #7

          @6thC You call it "Ridiculing", I call it "common sense" or "relevancy". Thank you for your help and contribution.

          @raven-worx First: there's nothing free in life.
          Second: Qt is not free. Opensource and licensed products don't mean free, far from that.
          Third: I am not a Qt API developer, it's not my job.
          Don't get mad but here I have a real question for you: would you accept to be slapped for free?

          @Snotboogie Thanks a lot for the hint.

          Since a solution through Qt does not exist we have to use win32 API for Windows platforms. This function works pretty well for me (windows 8 & 8.1):

          setWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_NOACTIVATE);
          

          Regarding Linux, setAttribute(Qt::WA_X11DoNotAcceptFocus); was working fine. But only for Qt 4.8, I have not tried it on Qt 5s yet.

          1 Reply Last reply
          0
          • 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