Skip to content

Commit 94aaadb

Browse files
committed
Port code to newer version
1 parent 0f86f79 commit 94aaadb

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/mainwindow.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,30 @@ MainWindow::MainWindow(QWidget *parent) :
3737
_exceptionGroup.addButton(_pUi->chkGatewayPathUnavailable, QModbusPdu::GatewayPathUnavailable);
3838

3939
connect(&_exceptionGroup, QOverload<int, bool>::of(&QButtonGroup::idToggled), this,
40-
[=](int id, bool checked){
41-
if (checked)
42-
{
43-
_pSlaveModbus->setException(static_cast<QModbusPdu::ExceptionCode>(id));
44-
}
45-
});
40+
[=, this](int id, bool checked) {
41+
if (checked)
42+
{
43+
_pSlaveModbus->setException(static_cast<QModbusPdu::ExceptionCode>(id));
44+
}
45+
});
4646

4747
/** Handle error recurrence group **/
4848
_bErrorOnce = true;
4949
_errorRecurrenceGroup.addButton(_pUi->optErrorOnce, true);
5050
_errorRecurrenceGroup.addButton(_pUi->optErrorPersistent, false);
5151

5252
connect(&_errorRecurrenceGroup, QOverload<int>::of(&QButtonGroup::idClicked), this,
53-
[=](int id){
54-
_bErrorOnce = static_cast<bool>(id);
55-
});
53+
[=, this](int id) { _bErrorOnce = static_cast<bool>(id); });
5654

5755
connect(_pSlaveModbus, &TestSlaveModbus::requestProcessed, this, &MainWindow::handleRequestProcessed);
5856

5957
/** Auto increment **/
6058
_bAutoInc = false;
61-
connect(_pUi->checkAutoIncrement, &QCheckBox::stateChanged, this,
62-
[=](int state){
63-
_bAutoInc = (state == Qt::Checked);
64-
_pIncGraph->setState(_bAutoInc);
65-
});
59+
60+
connect(_pUi->checkAutoIncrement, &QCheckBox::checkStateChanged, this, [this](Qt::CheckState state) {
61+
_bAutoInc = state;
62+
_pIncGraph->setState(_bAutoInc);
63+
});
6664

6765
/** Setup registerView **/
6866
_pUi->tblRegData->setModel(_pRegisterDataModel);

src/registerdatamodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int RegisterDataModel::columnCount(const QModelIndex & /*parent*/) const
4242

4343
QVariant RegisterDataModel::data(const QModelIndex &index, int role) const
4444
{
45-
const int registerAddress = index.row() * _cRegistersPerRow + index.column();
45+
const uint registerAddress = index.row() * _cRegistersPerRow + index.column();
4646
if (role == Qt::ToolTipRole)
4747
{
4848
if (registerAddress < _pTestSlaveData->size())
@@ -84,7 +84,7 @@ Qt::ItemFlags RegisterDataModel::flags(const QModelIndex & index) const
8484

8585
Qt::ItemFlags flags = Qt::NoItemFlags;
8686

87-
const int registerAddress = index.row() * _cRegistersPerRow + index.column();
87+
const uint registerAddress = index.row() * _cRegistersPerRow + index.column();
8888

8989
if (registerAddress < _pTestSlaveData->size())
9090
{

0 commit comments

Comments
 (0)