QtGui.QLineEdit
A QtGui.QLineEdit is a widget that allows to enter and edit a single line of plain text. There are undo and redo, cut and paste, and drag & drop functions available for the widget.
#!/usr/bin/python
# -*- coding: utf-8 -*- """
ZetCode PyQt4 tutorial This example shows text which
is entered in a QtGui.QLineEdit
in a QtGui.QLabel widget. author: Jan Bodnar
website: zetcode.com
last edited: August 2011
""" import sys
from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self):
super(Example, self).__init__() self.initUI() def initUI(self): self.lbl = QtGui.QLabel(self)
qle = QtGui.QLineEdit(self) qle.move(60, 100)
self.lbl.move(60, 40) qle.textChanged[str].connect(self.onChanged) self.setGeometry(300, 300, 280, 170)
self.setWindowTitle('QtGui.QLineEdit')
self.show() def onChanged(self, text): self.lbl.setText(text)
self.lbl.adjustSize() def main(): app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_()) if __name__ == '__main__':
main()
This example shows a line edit widget and a label. The text that we key in the line edit is displayed immediately in the label widget.
qle = QtGui.QLineEdit(self)
The QtGui.QLineEdit widget is created.
qle.textChanged[str].connect(self.onChanged)
If the text in the line edit widget changes, we call the onChanged() method.
def onChanged(self, text):
self.lbl.setText(text)
self.lbl.adjustSize()
Inside the onChanged() method, we set the typed text to the label widget. We call the adjustSize()method to adjust the size of the label to the length of the text.
Figure: QtGui.QLineEdit
QtGui.QLineEdit的更多相关文章
- QLineEdit 自动完成(使用setCompleter,内含一个ListView)
-------------------------------------CompleteLineEdit.h------------------------------------- #ifndef ...
- pyqt pyside QLineEdit 重写键盘事件
pyqt pyside QLineEdit 重写键盘事件 def keyPressEvent(self, event): if (event.modifiers() & QtCore.Qt.S ...
- QtGui.QInputDialog
The QtGui.QInputDialog provides a simple convenience dialog to get a single value from the user. The ...
- PyQt4入门学习笔记(五)
PyQt4里的对话框 对话框是大多数GUI应用中不可分割的一部分.一个对话框是两者或多者的会话.在GUI内,对话框是应用向人说话的方式.一个对话框可以用来输入数据,修改数据,改变应用设置等等. QtG ...
- PyQt4入门学习笔记(三)
# PyQt4入门学习笔记(三) PyQt4内的布局 布局方式是我们控制我们的GUI页面内各个控件的排放位置的.我们可以通过两种基本方式来控制: 1.绝对位置 2.layout类 绝对位置 这种方式要 ...
- Pyqt+QRcode 生成 识别 二维码
1.生成二维码 python生成二维码是件很简单的事,使用第三方库Python QRCode就可生成二维码,我用Pyqt给QRcode打个壳 一.python-qrcode介绍 python-qrco ...
- linux下使用多线程编写的聊天室
自从开始学linux网络编程后就想写个聊天室,一开始原本打算用多进程的方式来写,可是发觉进程间的通信有点麻烦,而且开销也大,后来想用多线程能不能实现呢,于是便去看了一下linux里线程的用法,实际上只 ...
- python GUI输入窗口
为了解决 sublime text 下 python 的 raw_input() 函数无法起效,便萌生了个用 GUI 窗口来获取输入的想法,一开始想用 Tkinter,后来想了下还是用 PyQt 吧, ...
- Pyqt 一个简单的浏览器
使用QtWebKit 做一个简单的浏览器. mybrowserUI.ui <?xml version="1.0" encoding="UTF-8"?> ...
随机推荐
- bzoj 3772
感觉做这种题收获很大. 1.DFS序(广义上)除了用于静态子树操作,也可以用来做点到根的路上某些信息的统计(如点到根的路径上标记了多少个点),如果在加上lca,就可以支持路径的信息查询. 2.树上的可 ...
- 一个iframe注入漏洞,也是微软的 Application["error"] 漏洞
最近学校进行安全等级评估,有人给我打电话,说我之前写的一个网站存在iframe注入漏洞,页面是error页面.我于是用netsparker扫描了自己的网站,果然发现error页面存在漏洞,我写网站的时 ...
- bosondata/chrome-prerender: Render JavaScript-rendered page as HTML/PDF/mhtml/png/jpeg using headless Chrome
bosondata/chrome-prerender: Render JavaScript-rendered page as HTML/PDF/mhtml/png/jpeg using headles ...
- X86调用约定 calling convention
http://zh.wikipedia.org/wiki/X86%E8%B0%83%E7%94%A8%E7%BA%A6%E5%AE%9A 这里描述了在x86芯片架构上的调用约定(calling con ...
- C语言之数组中你所不在意的重要知识
#include<stdio.h> void simpleArray(); void main() { simpleArray(); } //数组的简单操作 void simpleArra ...
- FIS常用命令
命令 用途 简写 fis --version 查看版本 fis -v fis install 安装 fis release 发布项目 fis server start 启动一个服务器用于预览项 ...
- Java垃圾回收精粹 — Part2
Java垃圾回收精粹分4个部分,本篇是第2部分.在第2部分里介绍了Hotspot中的堆结构.对象分配以及次要回收. Hotspot中的堆结构 理解不同的收集器的工作方式,是探讨Java堆结构如何支持分 ...
- 用 Redis 实现分布式锁(分析)
文章转自:http://www.jeffkit.info/2011/07/1000/ Redis有一系列的命令,特点是以NX结尾,NX是Not eXists的缩写,如SETNX命令就应该理解为:SET ...
- EventBus (一) 使用详解——初步使用EventBus
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 前言:EventBus是上周项目中用到的,网上的文章大都一样,或者过时,有用的没几篇,经过琢磨,请教他人,也终于弄清楚点眉目,记 ...
- Android 下文件cannot execute - Permission denied
安卓下执行交叉编译的可执行文件发现提示不允许. 原因是mount的方式问题,root后运行 su mount -o rw,remount /mnt/sdcard 就可以了 mount -o rw,re ...