PySide6开发-03-QLineEdit

1. 参考

# QtWidgets.pyi
class QLineEdit(PySide6.QtWidgets.QWidget):

    LeadingPosition          : QLineEdit.ActionPosition = ... # 0x0
    TrailingPosition         : QLineEdit.ActionPosition = ... # 0x1
    Normal                   : QLineEdit.EchoMode = ... # 0x0
    NoEcho                   : QLineEdit.EchoMode = ... # 0x1
    Password                 : QLineEdit.EchoMode = ... # 0x2
    PasswordEchoOnEdit       : QLineEdit.EchoMode = ... # 0x3

    class ActionPosition(Enum):

        LeadingPosition          : QLineEdit.ActionPosition = ... # 0x0
        TrailingPosition         : QLineEdit.ActionPosition = ... # 0x1

    class EchoMode(Enum):

        Normal                   : QLineEdit.EchoMode = ... # 0x0
        NoEcho                   : QLineEdit.EchoMode = ... # 0x1
        Password                 : QLineEdit.EchoMode = ... # 0x2
        PasswordEchoOnEdit       : QLineEdit.EchoMode = ... # 0x3


    @overload
    def __init__(self, arg__1:str, parent:Optional[PySide6.QtWidgets.QWidget]=...) -> None: ...
    @overload
    def __init__(self, parent:Optional[PySide6.QtWidgets.QWidget]=...) -> None: ...

    @overload
    def addAction(self, action:PySide6.QtGui.QAction) -> None: ...
    @overload
    def addAction(self, action:PySide6.QtGui.QAction, position:PySide6.QtWidgets.QLineEdit.ActionPosition) -> None: ...
    @overload
    def addAction(self, arg__1:PySide6.QtGui.QAction) -> None: ...
    @overload
    def addAction(self, icon:Union[PySide6.QtGui.QIcon, PySide6.QtGui.QPixmap], position:PySide6.QtWidgets.QLineEdit.ActionPosition) -> PySide6.QtGui.QAction: ...
    def alignment(self) -> PySide6.QtCore.Qt.Alignment: ...
    def backspace(self) -> None: ...
    def changeEvent(self, arg__1:PySide6.QtCore.QEvent) -> None: ...
    def clear(self) -> None: ...
    def completer(self) -> PySide6.QtWidgets.QCompleter: ...
    def contextMenuEvent(self, arg__1:PySide6.QtGui.QContextMenuEvent) -> None: ...
    def copy(self) -> None: ...
    def createStandardContextMenu(self) -> PySide6.QtWidgets.QMenu: ...
    def cursorBackward(self, mark:bool, steps:int=...) -> None: ...
    def cursorForward(self, mark:bool, steps:int=...) -> None: ...
    def cursorMoveStyle(self) -> PySide6.QtCore.Qt.CursorMoveStyle: ...
    def cursorPosition(self) -> int: ...
    def cursorPositionAt(self, pos:PySide6.QtCore.QPoint) -> int: ...
    def cursorRect(self) -> PySide6.QtCore.QRect: ...
    def cursorWordBackward(self, mark:bool) -> None: ...
    def cursorWordForward(self, mark:bool) -> None: ...
    def cut(self) -> None: ...
    def del_(self) -> None: ...
    def deselect(self) -> None: ...
    def displayText(self) -> str: ...
    def dragEnabled(self) -> bool: ...
    def dragEnterEvent(self, arg__1:PySide6.QtGui.QDragEnterEvent) -> None: ...
    def dragLeaveEvent(self, e:PySide6.QtGui.QDragLeaveEvent) -> None: ...
    def dragMoveEvent(self, e:PySide6.QtGui.QDragMoveEvent) -> None: ...
    def dropEvent(self, arg__1:PySide6.QtGui.QDropEvent) -> None: ...
    def echoMode(self) -> PySide6.QtWidgets.QLineEdit.EchoMode: ...
    def end(self, mark:bool) -> None: ...
    def event(self, arg__1:PySide6.QtCore.QEvent) -> bool: ...
    def focusInEvent(self, arg__1:PySide6.QtGui.QFocusEvent) -> None: ...
    def focusOutEvent(self, arg__1:PySide6.QtGui.QFocusEvent) -> None: ...
    def hasAcceptableInput(self) -> bool: ...
    def hasFrame(self) -> bool: ...
    def hasSelectedText(self) -> bool: ...
    def home(self, mark:bool) -> None: ...
    def initStyleOption(self, option:PySide6.QtWidgets.QStyleOptionFrame) -> None: ...
    def inputMask(self) -> str: ...
    def inputMethodEvent(self, arg__1:PySide6.QtGui.QInputMethodEvent) -> None: ...
    @overload
    def inputMethodQuery(self, arg__1:PySide6.QtCore.Qt.InputMethodQuery) -> Any: ...
    @overload
    def inputMethodQuery(self, property:PySide6.QtCore.Qt.InputMethodQuery, argument:Any) -> Any: ...
    def insert(self, arg__1:str) -> None: ...
    def isClearButtonEnabled(self) -> bool: ...
    def isModified(self) -> bool: ...
    def isReadOnly(self) -> bool: ...
    def isRedoAvailable(self) -> bool: ...
    def isUndoAvailable(self) -> bool: ...
    def keyPressEvent(self, arg__1:PySide6.QtGui.QKeyEvent) -> None: ...
    def keyReleaseEvent(self, arg__1:PySide6.QtGui.QKeyEvent) -> None: ...
    def maxLength(self) -> int: ...
    def minimumSizeHint(self) -> PySide6.QtCore.QSize: ...
    def mouseDoubleClickEvent(self, arg__1:PySide6.QtGui.QMouseEvent) -> None: ...
    def mouseMoveEvent(self, arg__1:PySide6.QtGui.QMouseEvent) -> None: ...
    def mousePressEvent(self, arg__1:PySide6.QtGui.QMouseEvent) -> None: ...
    def mouseReleaseEvent(self, arg__1:PySide6.QtGui.QMouseEvent) -> None: ...
    def paintEvent(self, arg__1:PySide6.QtGui.QPaintEvent) -> None: ...
    def paste(self) -> None: ...
    def placeholderText(self) -> str: ...
    def redo(self) -> None: ...
    def selectAll(self) -> None: ...
    def selectedText(self) -> str: ...
    def selectionEnd(self) -> int: ...
    def selectionLength(self) -> int: ...
    def selectionStart(self) -> int: ...
    def setAlignment(self, flag:PySide6.QtCore.Qt.Alignment) -> None: ...
    def setClearButtonEnabled(self, enable:bool) -> None: ...
    def setCompleter(self, completer:PySide6.QtWidgets.QCompleter) -> None: ...
    def setCursorMoveStyle(self, style:PySide6.QtCore.Qt.CursorMoveStyle) -> None: ...
    def setCursorPosition(self, arg__1:int) -> None: ...
    def setDragEnabled(self, b:bool) -> None: ...
    def setEchoMode(self, arg__1:PySide6.QtWidgets.QLineEdit.EchoMode) -> None: ...
    def setFrame(self, arg__1:bool) -> None: ...
    def setInputMask(self, inputMask:str) -> None: ...
    def setMaxLength(self, arg__1:int) -> None: ...
    def setModified(self, arg__1:bool) -> None: ...
    def setPlaceholderText(self, arg__1:str) -> None: ...
    def setReadOnly(self, arg__1:bool) -> None: ...
    def setSelection(self, arg__1:int, arg__2:int) -> None: ...
    def setText(self, arg__1:str) -> None: ...
    @overload
    def setTextMargins(self, left:int, top:int, right:int, bottom:int) -> None: ...
    @overload
    def setTextMargins(self, margins:PySide6.QtCore.QMargins) -> None: ...
    def setValidator(self, arg__1:PySide6.QtGui.QValidator) -> None: ...
    def sizeHint(self) -> PySide6.QtCore.QSize: ...
    def text(self) -> str: ...
    def textMargins(self) -> PySide6.QtCore.QMargins: ...
    def timerEvent(self, arg__1:PySide6.QtCore.QTimerEvent) -> None: ...
    def undo(self) -> None: ...
    def validator(self) -> PySide6.QtGui.QValidator: ...

2. 代码

简单使用下QLineEdit类中的方法。

方法作用
setReadOnly(self, arg__1:bool)设置只读
setText(self, arg__1:str)设置内容
text(self)获取内容
import sys
from PySide6.QtWidgets import QApplication, QMainWindow
from ui_test import Ui_MainWindow


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.pushButton.clicked.connect(self.pushbuttonSlot)

        self.ui.lineEdit.setReadOnly(True)
        self.ui.lineEdit.setText("QLineEdit")

    def pushbuttonSlot(self):
        print(self.ui.lineEdit.text())

if __name__ == "__main__":
    app = QApplication(sys.argv)
    mainwindow = MainWindow()
    mainwindow.show()
    sys.exit(app.exec())
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lljwork2021

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值