You need to use the label's setBuddy method to get the accelerator to work:
self.label = QtGui.QLabel('&Title:', self)
self.textedit = QtGui.QTextEdit(self)
self.label.setBuddy(self.textedit)
题
How do I assign an accelerator that would put focus on a QTextEdit
? I'm a PySide newb and I tried what worked in wxPython
, which is to make a label before the text edit and give it an accelerator, however I tried doing both '&Title:'
and '_Title:'
but none of them gave it an accelerator of T
like I wanted. How do I do that?
解决方案
You need to use the label's setBuddy method to get the accelerator to work:
self.label = QtGui.QLabel('&Title:', self)
self.textedit = QtGui.QTextEdit(self)
self.label.setBuddy(self.textedit)