diff --git a/commandwidget.cpp b/commandwidget.cpp --- a/commandwidget.cpp +++ b/commandwidget.cpp @@ -77,6 +77,16 @@ 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() diff --git a/commandwidget.h b/commandwidget.h --- a/commandwidget.h +++ b/commandwidget.h @@ -46,6 +46,9 @@ signals: private: Ui::CommandWidget *ui; + QString storedAsciiText; + QString storedHexText; + bool isASCIIMode(); // true: ascii mode, false hex mode private slots: