added keyboard shortcut (ctrl-f) for focusing the search box

This commit is contained in:
2023-01-07 13:06:35 +01:00
parent f2a865d5e1
commit d562ce1c66

View File

@ -1,5 +1,6 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QLineEdit, QPushButton, QHBoxLayout, QStyle
from PyQt5.QtGui import QKeySequence
from PyQt5.QtWidgets import QWidget, QLineEdit, QPushButton, QHBoxLayout, QStyle, QShortcut
class SearchBox(QWidget):
@ -26,6 +27,10 @@ class SearchBox(QWidget):
btn.clicked.connect(self.txt.clear)
#TODO: where should this go? probably top level MainWindow...
shortcut = QShortcut(QKeySequence("Ctrl+F"), self)
shortcut.activated.connect(txt.setFocus)
# behave like encapsulated QLineEdit
def __getattr__(self, name):