PyQt4—QLabel--setBuddy
来源:互联网 发布:游戏编程学校 编辑:程序博客网 时间:2024/04/27 02:33
# -*- coding: UTF-8 –*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))
class FindCell(QDialog):
def __init__(self,parent=None):
super(FindCell,self).__init__(parent)
self.setWindowTitle('Find Cell')
lblFind=QLabel('&Find')
editFind=QLineEdit()
#lblFind.setBuddy(editFind)
btnOk=QPushButton('&OK')
btnCancel=QPushButton('&Cancel')
mainLayout=QGridLayout(self)
mainLayout.addWidget(lblFind,0,0)
mainLayout.addWidget(editFind,0,1,1,2)
mainLayout.addWidget(btnOk,1,1)
mainLayout.addWidget(btnCancel,1,2)
app=QApplication(sys.argv)
dlg=FindCell()
dlg.show()
sys.exit(app.exec_())
# -*- coding: UTF-8 –*-
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))
class FindCell(QDialog):
def __init__(self,parent=None):
super(FindCell,self).__init__(parent)
self.setWindowTitle('Find Cell')
lblFind=QLabel('&Find')
editFind=QLineEdit()
lblFind.setBuddy(editFind)
btnOk=QPushButton('&OK')
btnCancel=QPushButton('&Cancel')
mainLayout=QGridLayout(self)
mainLayout.addWidget(lblFind,0,0)
mainLayout.addWidget(editFind,0,1,1,2)
mainLayout.addWidget(btnOk,1,1)
mainLayout.addWidget(btnCancel,1,2)
app=QApplication(sys.argv)
dlg=FindCell()
dlg.show()
sys.exit(app.exec_())
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlabel.html#setBuddy
QLabel.setBuddy (self, QWidget)
Sets this label's buddy to buddy.
When the user presses the shortcut key indicated by this label, the keyboard focus is transferred to the label's buddy widget.
The buddy mechanism is only available for QLabels that contain text in which one character is prefixed with an ampersand, '&'. This character is set as the shortcut key. See the QKeySequence.mnemonic() documentation for details (to display an actual ampersand, use '&&').
In a dialog, you might create two data entry widgets and a label for each, and set up the geometry layout so each label is just to the left of its data entry widget (its "buddy"), for example:
QLineEdit *nameEd = new QLineEdit(this); QLabel *nameLb = new QLabel("&Name:", this); nameLb->setBuddy(nameEd); QLineEdit *phoneEd = new QLineEdit(this); QLabel *phoneLb = new QLabel("&Phone:", this); phoneLb->setBuddy(phoneEd); // (layout setup not shown)
With the code above, the focus jumps to the Name field when the user presses Alt+N, and to the Phone field when the user presses Alt+P.
To unset a previously set buddy, call this function with buddy set to 0.
See also buddy(), setText(), QShortcut, and setAlignment().
- PyQt4—QLabel--setBuddy
- Qt QLabel::setBuddy函数
- Qt QLabel::setBuddy函数
- Qt QLabel::setBuddy函数
- Qt QLabel::setBuddy函数
- Qt QLabel::setBuddy函数
- Qt QLabel::setBuddy函数
- Qt QLabel::setBuddy函数简介
- QLabel
- QLabel
- QLabel
- QLabel
- QLabel
- Qlabel
- setBuddy()
- setBuddy函数
- Pyqt4
- pyqt4
- OpenUP:基本流程概念
- 拉格朗日函数
- JSP自定义标签的页面解析生命周期及线程安全
- 在Ubuntu10.10下安装arm-linux交叉编译环境
- 详解各种百度蜘蛛代码的含义
- PyQt4—QLabel--setBuddy
- FOR脚本的用法
- Android重力感应Demo
- java
- PL/SQL 学习笔记!
- 小记
- Introduction to fixed-width integers
- Junit源码分析
- shellcode验证方法