TabWight

//修改站号
void CDlgParamView::OnPushButton_2_Tab8Clicked()
{
// int iSel = m_listStation.GetSelectionMark();
int iSel = ui->tableView_Tab8->currentIndex().row();
if (iSel < 0)
{
AfxMessageBox(_T("请选择站号!"), MB_ICONWARNING);
}
CString strNum = _T(""), strIp = _T(""), strPort = _T("");
QModelIndex indexstrNum = model->index(iSel, 0);
QString tempstrNum = indexstrNum.data().toString();
strNum = QS2CS(tempstrNum);
QModelIndex indexstrIp = model->index(iSel, 1);
QString tempstrIp = indexstrIp.data().toString();
strIp = QS2CS(tempstrIp);
QModelIndex indexstrPort = model->index(iSel, 2);
QString tempstrPort = indexstrPort.data().toString();
strPort = QS2CS(tempstrPort);
CDlgStationOp dlgStationOp(1, strNum, strIp, strPort);
dlgStationOp.SetThisParent(this);
if (dlgStationOp.exec() == QDialog::Accepted)
{
QModelIndex index_0 = model->index(iSel, 0);//选中行第0列的内容
QModelIndex index_1 = model->index(iSel, 1);//选中行第1列的内容
QModelIndex index_2 = model->index(iSel, 2);//选中行第2列的内容

model->setData(index_0, QVariant::fromValue(CS2QS(dlgStationOp.m_strNum)));
model->setData(index_1, QVariant::fromValue(CS2QS(dlgStationOp.m_strIpAddr)));
model->setData(index_2, QVariant::fromValue(CS2QS(dlgStationOp.m_strPort)));
}
}

 

//删除站号
void CDlgParamView::OnPushButton_3_Tab8Clicked()
{
if (AfxMessageBox(_T("确定要删除该站号码?"), MB_YESNO | MB_ICONQUESTION) == IDYES)
{
int iSel = ui->tableView_Tab8->currentIndex().row();
model->removeRow(iSel);
}
}

QStringList list;
list << CS2QS(dlgStationOp.m_strNum) << CS2QS(dlgStationOp.m_strIpAddr) << CS2QS(dlgStationOp.m_strPort);
QList<QStandardItem*> listQStand = QList<QStandardItem*>();
listQStand << new QStandardItem(list[0])
<< new QStandardItem(list[1])
<< new QStandardItem(list[2]);
model->insertRow(model->rowCount(), listQStand); //在第0行插入一条记录

转载于:https://www.cnblogs.com/ShiShouTHS/p/11083283.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值