Add option to truncate or pad variable value

This commit is contained in:
WarmUpTill
2024-03-27 10:24:31 +01:00
committed by WarmUpTill
parent 3fe8ea8961
commit 14dd390680
6 changed files with 232 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
#include "single-char-selection.hpp"
namespace advss {
SingleCharSelection::SingleCharSelection(QWidget *parent) : QLineEdit(parent)
{
setMaxLength(1);
setMaximumWidth(50);
connect(this, &QLineEdit::textChanged, this,
&SingleCharSelection::CharChanged);
}
void SingleCharSelection::HandleTextChanged(const QString &text)
{
if (text.length() == 1) {
emit CharChanged(text);
} else if (text.length() > 1) {
setText(text.left(1));
}
}
} // namespace advss