mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-20 08:15:46 -05:00
Add option to truncate or pad variable value
This commit is contained in:
22
lib/utils/single-char-selection.cpp
Normal file
22
lib/utils/single-char-selection.cpp
Normal 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
|
||||
Reference in New Issue
Block a user