The WindowDoesNotAcceptFocus flag is making me thirsty!!!!!!!
-
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.
-
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)
-
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 ?
-
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 ?
@deblin Hi! Es gibt Forum in Deutscher Sprache hier: https://forum.qt.io/category/28/german
-
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 ?
@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?
-
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 ....
-
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 ....
-
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.