Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 09:27:16

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QLINEEDIT_H
0006 #define QLINEEDIT_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtWidgets/qframe.h>
0010 #include <QtGui/qtextcursor.h>
0011 #include <QtCore/qstring.h>
0012 #include <QtCore/qmargins.h>
0013 
0014 QT_REQUIRE_CONFIG(lineedit);
0015 
0016 QT_BEGIN_NAMESPACE
0017 
0018 class QValidator;
0019 class QMenu;
0020 class QLineEditPrivate;
0021 class QCompleter;
0022 class QStyleOptionFrame;
0023 class QAbstractSpinBox;
0024 class QDateTimeEdit;
0025 class QIcon;
0026 class QToolButton;
0027 
0028 class Q_WIDGETS_EXPORT QLineEdit : public QWidget
0029 {
0030     Q_OBJECT
0031 
0032     Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
0033     Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
0034     Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
0035     Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
0036     Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
0037     Q_PROPERTY(QString displayText READ displayText)
0038     Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
0039     Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
0040     Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
0041     Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
0042     Q_PROPERTY(QString selectedText READ selectedText)
0043     Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
0044     Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
0045     Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
0046     Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
0047     Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
0048     Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
0049     Q_PROPERTY(Qt::CursorMoveStyle cursorMoveStyle READ cursorMoveStyle WRITE setCursorMoveStyle)
0050     Q_PROPERTY(bool clearButtonEnabled READ isClearButtonEnabled WRITE setClearButtonEnabled)
0051 public:
0052     enum ActionPosition {
0053         LeadingPosition,
0054         TrailingPosition
0055     };
0056     Q_ENUM(ActionPosition)
0057 
0058     explicit QLineEdit(QWidget *parent = nullptr);
0059     explicit QLineEdit(const QString &, QWidget *parent = nullptr);
0060     ~QLineEdit();
0061 
0062     QString text() const;
0063 
0064     QString displayText() const;
0065 
0066     QString placeholderText() const;
0067     void setPlaceholderText(const QString &);
0068 
0069     int maxLength() const;
0070     void setMaxLength(int);
0071 
0072     void setFrame(bool);
0073     bool hasFrame() const;
0074 
0075     void setClearButtonEnabled(bool enable);
0076     bool isClearButtonEnabled() const;
0077 
0078     enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit };
0079     Q_ENUM(EchoMode)
0080     EchoMode echoMode() const;
0081     void setEchoMode(EchoMode);
0082 
0083     bool isReadOnly() const;
0084     void setReadOnly(bool);
0085 
0086 #ifndef QT_NO_VALIDATOR
0087     void setValidator(const QValidator *);
0088     const QValidator * validator() const;
0089 #endif
0090 
0091 #if QT_CONFIG(completer)
0092     void setCompleter(QCompleter *completer);
0093     QCompleter *completer() const;
0094 #endif
0095 
0096     QSize sizeHint() const override;
0097     QSize minimumSizeHint() const override;
0098 
0099     int cursorPosition() const;
0100     void setCursorPosition(int);
0101     int cursorPositionAt(const QPoint &pos);
0102 
0103     void setAlignment(Qt::Alignment flag);
0104     Qt::Alignment alignment() const;
0105 
0106     void cursorForward(bool mark, int steps = 1);
0107     void cursorBackward(bool mark, int steps = 1);
0108     void cursorWordForward(bool mark);
0109     void cursorWordBackward(bool mark);
0110     void backspace();
0111     void del();
0112     void home(bool mark);
0113     void end(bool mark);
0114 
0115     bool isModified() const;
0116     void setModified(bool);
0117 
0118     void setSelection(int, int);
0119     bool hasSelectedText() const;
0120     QString selectedText() const;
0121     int selectionStart() const;
0122     int selectionEnd() const;
0123     int selectionLength() const;
0124 
0125     bool isUndoAvailable() const;
0126     bool isRedoAvailable() const;
0127 
0128     void setDragEnabled(bool b);
0129     bool dragEnabled() const;
0130 
0131     void setCursorMoveStyle(Qt::CursorMoveStyle style);
0132     Qt::CursorMoveStyle cursorMoveStyle() const;
0133 
0134     QString inputMask() const;
0135     void setInputMask(const QString &inputMask);
0136     bool hasAcceptableInput() const;
0137 
0138     void setTextMargins(int left, int top, int right, int bottom);
0139     void setTextMargins(const QMargins &margins);
0140     QMargins textMargins() const;
0141 
0142 #if QT_CONFIG(action)
0143     using QWidget::addAction;
0144     void addAction(QAction *action, ActionPosition position);
0145     QAction *addAction(const QIcon &icon, ActionPosition position);
0146 #endif
0147 
0148 public Q_SLOTS:
0149     void setText(const QString &);
0150     void clear();
0151     void selectAll();
0152     void undo();
0153     void redo();
0154 #ifndef QT_NO_CLIPBOARD
0155     void cut();
0156     void copy() const;
0157     void paste();
0158 #endif
0159 
0160 public:
0161     void deselect();
0162     void insert(const QString &);
0163 #ifndef QT_NO_CONTEXTMENU
0164     QMenu *createStandardContextMenu();
0165 #endif
0166 
0167 Q_SIGNALS:
0168     void textChanged(const QString &);
0169     void textEdited(const QString &);
0170     void cursorPositionChanged(int, int);
0171     void returnPressed();
0172     void editingFinished();
0173     void selectionChanged();
0174     void inputRejected();
0175 
0176 protected:
0177     void mousePressEvent(QMouseEvent *) override;
0178     void mouseMoveEvent(QMouseEvent *) override;
0179     void mouseReleaseEvent(QMouseEvent *) override;
0180     void mouseDoubleClickEvent(QMouseEvent *) override;
0181     void keyPressEvent(QKeyEvent *) override;
0182     void keyReleaseEvent(QKeyEvent *) override;
0183     void focusInEvent(QFocusEvent *) override;
0184     void focusOutEvent(QFocusEvent *) override;
0185     void paintEvent(QPaintEvent *) override;
0186 #if QT_CONFIG(draganddrop)
0187     void dragEnterEvent(QDragEnterEvent *) override;
0188     void dragMoveEvent(QDragMoveEvent *e) override;
0189     void dragLeaveEvent(QDragLeaveEvent *e) override;
0190     void dropEvent(QDropEvent *) override;
0191 #endif
0192     void changeEvent(QEvent *) override;
0193 #ifndef QT_NO_CONTEXTMENU
0194     void contextMenuEvent(QContextMenuEvent *) override;
0195 #endif
0196 
0197     void inputMethodEvent(QInputMethodEvent *) override;
0198     virtual void initStyleOption(QStyleOptionFrame *option) const;
0199 public:
0200     QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
0201     Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const;
0202     void timerEvent(QTimerEvent *) override;
0203     bool event(QEvent *) override;
0204 protected:
0205     QRect cursorRect() const;
0206 
0207 public:
0208 
0209 private:
0210     friend class QAbstractSpinBox;
0211     friend class QAccessibleLineEdit;
0212     friend class QComboBox;
0213 #ifdef QT_KEYPAD_NAVIGATION
0214     friend class QDateTimeEdit;
0215 #endif
0216     Q_DISABLE_COPY(QLineEdit)
0217     Q_DECLARE_PRIVATE(QLineEdit)
0218 };
0219 
0220 QT_END_NAMESPACE
0221 
0222 #endif // QLINEEDIT_H