DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dlineedit.h
浏览该文件的文档.
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DLINEEDIT_H
6#define DLINEEDIT_H
7
8#include <dobject.h>
9#include <dtkwidget_global.h>
10
11#include <QWidget>
12#include <QLineEdit>
13#include <QHBoxLayout>
14
15DWIDGET_BEGIN_NAMESPACE
16
17class DLineEditPrivate;
18class DStyleOptionLineEdit;
19class LIBDTKWIDGETSHARED_EXPORT DLineEdit : public QWidget, public DTK_CORE_NAMESPACE::DObject
20{
21 Q_OBJECT
22 Q_DISABLE_COPY(DLineEdit)
23 D_DECLARE_PRIVATE(DLineEdit)
24 Q_PROPERTY(bool alert READ isAlert WRITE setAlert NOTIFY alertChanged)
25
26public:
27 DLineEdit(QWidget *parent = nullptr);
28 virtual ~DLineEdit() override;
29
30 QLineEdit *lineEdit() const;
31 void setPlaceholderText(const QString &);
32
33 void setAlert(bool isAlert);
34 bool isAlert() const;
35 void showAlertMessage(const QString &text, int duration = 3000);
36 void showAlertMessage(const QString &text, QWidget *follower, int duration = 3000);
37 void setAlertMessageAlignment(Qt::Alignment alignment);
38 Qt::Alignment alertMessageAlignment() const;
39 void hideAlertMessage();
40
41 void setLeftWidgets(const QList<QWidget *> &list);
42 void setRightWidgets(const QList<QWidget *> &list);
43
44 void setLeftWidgetsVisible(bool visible);
45 void setRightWidgetsVisible(bool visible);
46
47 void setClearButtonEnabled(bool enable);
48 bool isClearButtonEnabled() const;
49
50 void setText(const QString &text);
51 QString text();
52
53 void clear();
54
55 QLineEdit::EchoMode echoMode() const;
56 void setEchoMode(QLineEdit::EchoMode mode);
57
58 void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
59
60 bool speechToTextIsEnabled() const;
61 void setSpeechToTextEnabled(bool enable);
62
63 bool textToSpeechIsEnabled() const;
64 void setTextToSpeechEnabled(bool enable);
65
66 bool textToTranslateIsEnabled() const;
67 void setTextToTranslateEnabled(bool enable);
68
69 bool copyEnabled() const;
70 void setCopyEnabled(bool enable);
71
72 bool cutEnabled() const;
73 void setCutEnabled(bool enable);
74
75Q_SIGNALS:
76 void alertChanged(bool alert) const;
77 void focusChanged(bool onFocus) const;
78
79 void textChanged(const QString &);
80 void textEdited(const QString &);
81 void cursorPositionChanged(int, int);
82 void returnPressed();
83 void editingFinished();
84 void selectionChanged();
85
86protected:
87 DLineEdit(DLineEditPrivate &q, QWidget *parent);
88 bool eventFilter(QObject *watched, QEvent *event) override;
89 bool event(QEvent *event) override;
90
91 friend class DStyleOptionLineEdit;
92};
93
94DWIDGET_END_NAMESPACE
95
96#endif // DLINEEDIT_H
Definition dlineedit_p.h:20
DLineEdit一个聚合 QLineEdit 的输入框.
Definition dlineedit.h:20
Dtk::Widget::DLineEdit使用的样式配置.
Definition dstyleoption.h:92