diff --git a/commandedit.cpp b/commandedit.cpp --- a/commandedit.cpp +++ b/commandedit.cpp @@ -76,10 +76,12 @@ void CommandEdit::setMode(bool ascii) if (ascii) { setValidator(asciiValidator); + setText(QByteArray::fromHex(text().remove(" ").toLatin1())); } else { setValidator(hexValidator); + setText(text().toLatin1().toHex()); } } diff --git a/commandwidget.cpp b/commandwidget.cpp --- a/commandwidget.cpp +++ b/commandwidget.cpp @@ -77,16 +77,6 @@ void CommandWidget::onSendClicked() void CommandWidget::onASCIIToggled(bool checked) { ui->leCommand->setMode(checked); - if (checked) - { - storedHexText = ui->leCommand->text(); - ui->leCommand->setText(storedAsciiText); - } - else - { - storedAsciiText = ui->leCommand->text(); - ui->leCommand->setText(storedHexText); - } } bool CommandWidget::isASCIIMode()