ToolX 1.11.1 [e3f477f]
A GUI debug tool chain for diagnosing GVA systems
Loading...
Searching...
No Matches
password_delegate.h
Go to the documentation of this file.
1//
2// Copyright (c) 2026, Astute Systems PTY LTD
3//
4// This file is part of the VivoeX project developed by Astute Systems.
5//
6// License. See the LICENSE file in the project root for full license details.
7//
12
13#ifndef STREAMS_PASSWORD_DELEGATE_H
14#define STREAMS_PASSWORD_DELEGATE_H
15
16#include <QLineEdit>
17#include <QStyledItemDelegate>
18
19namespace toolx::streams {
20
24class PasswordDelegate : public QStyledItemDelegate
25{
26public:
27 using QStyledItemDelegate::QStyledItemDelegate;
28
32 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
33 const QModelIndex &index) const override
34 {
35 auto *editor = QStyledItemDelegate::createEditor(parent, option, index);
36 if (auto *line = qobject_cast<QLineEdit *>(editor)) {
37 line->setEchoMode(QLineEdit::Password);
38 }
39 return editor;
40 }
41
42protected:
44 void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override
45 {
46 QStyledItemDelegate::initStyleOption(option, index);
47 option->text = QString(index.data(Qt::EditRole).toString().size(), QChar(0x2022));
48 }
49};
50
51} // namespace toolx::streams
52
53#endif // STREAMS_PASSWORD_DELEGATE_H
Shows bullets instead of the text and edits the text as a password.
Definition password_delegate.h:25
void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override
Replace the text drawn in the cell with bullets.
Definition password_delegate.h:44
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Create a line editor that echoes bullets.
Definition password_delegate.h:32