summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2017-10-04 14:32:21 +0200
committerAndré Hartmann <aha_1980@gmx.de>2017-10-04 18:57:50 +0000
commit01df1b7a635b11c9d0985f9651cfa4ae3d037890 (patch)
tree191dfbbd1935796a3abdc919559975d70646e77e /examples
parentf4ae73d430d9bf2bd6432e8e4a4e44d2bf5d806a (diff)
CAN-Example: Disable Send button if frame id is emptyv5.10.0-beta1
Every CAN frame needs a CAN-ID to be sent. Disable the Send button with a informative tooltip if this condition is not met. Change-Id: I77033a36c4a45c136185135776ef79185dc548be Reviewed-by: Rolf Eike Beer <eb@emlix.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/serialbus/can/sendframebox.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/serialbus/can/sendframebox.cpp b/examples/serialbus/can/sendframebox.cpp
index a84222d..d7a25ba 100644
--- a/examples/serialbus/can/sendframebox.cpp
+++ b/examples/serialbus/can/sendframebox.cpp
@@ -157,6 +157,15 @@ SendFrameBox::SendFrameBox(QWidget *parent) :
m_ui->bitrateSwitchBox->setChecked(false);
});
+ auto frameIdTextChanged = [this]() {
+ const bool hasFrameId = !m_ui->frameIdEdit->text().isEmpty();
+ m_ui->sendButton->setEnabled(hasFrameId);
+ m_ui->sendButton->setToolTip(hasFrameId
+ ? QString() : tr("Cannot send because no Frame ID was given."));
+ };
+ connect(m_ui->frameIdEdit, &QLineEdit::textChanged, frameIdTextChanged);
+ frameIdTextChanged();
+
connect(m_ui->sendButton, &QPushButton::clicked, [this]() {
const uint frameId = m_ui->frameIdEdit->text().toUInt(nullptr, 16);
QString data = m_ui->payloadEdit->text();