yhm163email
yhm163email
采纳率0%
2016-05-13 03:49 阅读 1.6k

QT5的问题,具体形容在下面,请大神帮忙看一下

图片说明
输入条形码查询显示在最下面的Qlineedit中然后输入库存回车显示tableview中获取信息用的qnetwork这已经完成了,但是第一次输条形码回车输库存回车显示一条信息,第二次就变成2条同样的了,第三次三遍了,求助大神,求帮助啊,下面贴了代码图片说明上传的错误如上图,图片上的网络错误已经解决,上传状态都正常,只是上传数量的错误一直没有解决,第一条传了一遍,第二条传了两遍,第三条传了三遍

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • caozhy 从今以后生命中的每一秒都属于我爱的人 2016-05-13 03:56

    看下代码,估计是你使用的是相同的对象或者结构体,所以循环中修改它实际上冲掉了以前的,应该为每个条目new一个结构体或者对象,再赋值。

    点赞 评论 复制链接分享
  • qq423399099 小灸舞 2016-05-13 03:57

    那楼主每次回车输入结束后先清空一下你的控件
    楼主用的是啥显示控件?qtableWidget?

    点赞 评论 复制链接分享
  • QuantumEnergy QuantumEnergy 2016-05-13 04:31

    看情况或者是保存查询结果的变量没有清,最可能是table没有清除!

    点赞 评论 复制链接分享
  • yhm163email yhm163email 2016-05-13 06:46

    #include "maindialog.h"
    #include "ui_maindialog.h"
    #include "tools/globalvariable.h"

    MainDialog::MainDialog(QWidget *parent) :
    BasicDialog(parent),
    ui(new Ui::MainDialog)
    {
    this->setWindowFlags (Qt::FramelessWindowHint| Qt::WindowStaysOnTopHint);
    ui->setupUi(this);
    this->getGoods();
    this->init();
    }

    void MainDialog::init()
    {
    msgBox->raise();
    ui->staffLabel->setText(GlobalVariable::pcName);
    //初始化按钮
    this->initButton();
    this->initTableView();
    state = 0;
    }

    void MainDialog::initEdit()
    {

    ui->inputLineEdit->setFocus();
    QRegExp regExp("[0-9,.]{0,18}");
    ui->inputLineEdit->setValidator(new QRegExpValidator(regExp,this));
    

    }

    void MainDialog::initButton()
    {
    quitBt = new quitButton(this);
    quitBt->move(989,0);
    quitBt->setAutoDefault(false);
    connect(quitBt,&quitButton::clicked,this,&MainDialog::showWarning);
    }

    void MainDialog::initTableView()
    {
    goodsListModel = new MyStandardModel;
    goodsListModel->setHorizontalHeaderItem(0, new QStandardItem(QObject::tr("")));
    goodsListModel->setHorizontalHeaderItem(1, new QStandardItem(QObject::tr("商品自编码")));
    goodsListModel->setHorizontalHeaderItem(2, new QStandardItem(QObject::tr("商品条码")));
    goodsListModel->setHorizontalHeaderItem(3, new QStandardItem(QObject::tr("商品名称")));
    goodsListModel->setHorizontalHeaderItem(4, new QStandardItem(QObject::tr("当前数量")));
    goodsListModel->setHorizontalHeaderItem(5, new QStandardItem(QObject::tr("录入数量")));
    goodsListModel->setHorizontalHeaderItem(6, new QStandardItem(QObject::tr("状态")));

    ui->tableView->setModel(goodsListModel);
    ui->tableView->setColumnWidth(0,40);
    ui->tableView->setColumnWidth(1,120);
    ui->tableView->setColumnWidth(2,160);
    ui->tableView->setColumnWidth(3,300);
    ui->tableView->setColumnWidth(4,90);
    ui->tableView->setColumnWidth(5,90);
    ui->tableView->setColumnWidth(6,90);
    
    ui->tableView->hideColumn(10);
    ui->tableView->verticalHeader()->hide();
    ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    
    QFont font;
    font.setPointSize(10);
    ui->tableView->setStyleSheet("QTableView::item::selected{color:white;background:#337cc9}");
    ui->tableView->horizontalHeader()->setStyleSheet("QTableView::selected{background:#ffffff;}");
    ui->tableView->setFont(font);
    ui->tableView->horizontalHeader()->setMinimumHeight(42);
    ui->tableView->verticalHeader()->setDefaultSectionSize(42);
    

    }

    void MainDialog::getGoods()
    {
    netWorkCon *net = new netWorkCon(this);
    QList paramList;
    //url
    paramList.append("seller_name ="+GlobalVariable::pcName);
    net->conectNet(url,paramList);
    connect(net,&netWorkCon::connectFinished,this,&MainDialog::getGoodsFinished);
    }

    void MainDialog::getGoodsFinished(bool flag, QJsonDocument jsonResult)
    {
    if(flag)
    {
    if(jsonResult.isEmpty())
    {
    QMessageBox::information(this,"提示","尚未获取到任何数据,如果是第一次输入,请忽略,如果有历史数据,请联系管理员",QMessageBox::Yes);
    }
    else
    {
    QVariantMap result = jsonResult.toVariant().toMap();
    state = 100;
    for(int i=0;i {
    goodsListModel->setItem(i, 0, new QStandardItem(QString::number(i+1)));
    goodsListModel->setItem(i, 1, new QStandardItem(result["goods_commonid"].toString()));
    goodsListModel->setItem(i, 2, new QStandardItem(result["goods_serial"].toString()));
    goodsListModel->setItem(i, 3, new QStandardItem(result["goods_name"].toString()));
    goodsListModel->setItem(i, 4, new QStandardItem(result["goods_begin"].toString()));
    goodsListModel->setItem(i, 5, new QStandardItem(result["goods_storage"].toString()));
    goodsListModel->setItem(i, 6, new QStandardItem(state));
    }

        }
        connect(ui->inputLineEdit,&QLineEdit::returnPressed,this,&MainDialog::goodsSearch);
    }
    else
    {
        this->showMsgBox(tr("网络连接超时!"));
        this->setEnabled(true);
    }
    

    }

    void MainDialog::goodsSearch()
    {
    QString goods_ma = ui->inputLineEdit->text();
    if(goods_ma=="")
    {
    this->showMsgBox(tr("输入条形码或自编码不能为空!"));
    }
    else
    {
    netWorkCon *net = new netWorkCon(this);
    QList paramList;
    //url
    paramList.append("goods_ma="+goods_ma);
    net->conectNet(url,paramList);
    connect(net,&netWorkCon::connectFinished,this,&MainDialog::goodsSearchFinished);
    }
    }

    void MainDialog::goodsSearchFinished(bool flag, QJsonDocument jsonResult)
    {
    if(flag)
    {
    if(jsonResult.isEmpty())
    {
    this->showMsgBox(tr("商品不存在"));
    ui->inputLineEdit->clear();
    ui->inputLineEdit->setFocus();
    }
    else
    {
    QVariantMap _callbackInfo = jsonResult.toVariant().toMap();
    if(_callbackInfo["state"].toInt()==0)
    {
    ui->zbmLineEdit->setText(_callbackInfo["goods_commonid"].toString());
    ui->txmLineEdit->setText(_callbackInfo["goods_serial"].toString());
    ui->nameLineEdit->setText(_callbackInfo["goods_name"].toString());
    ui->kcLineEdit->setText(_callbackInfo["goods_storage"].toString());
    ui->inputLineEdit->setText("");
    ui->inkcLineEdit->setFocus();
    connect(ui->inkcLineEdit,&QLineEdit::returnPressed,this,&MainDialog::inputkc);
    }
    else if(_callbackInfo["state"].toInt()==-1)
    {
    this->showMsgBox(tr("条码错误"));
    ui->inputLineEdit->setText("");
    ui->inputLineEdit->setFocus();
    }
    else if(_callbackInfo["state"].toInt()==2)
    {
    name = _callbackInfo["seller_name"].toString();
    //qDebug()< QString str = name + "已盘存过此商品,是否继续?";
    if(QMessageBox::Yes == QMessageBox::question(this,
    "Question",
    str,
    QMessageBox::Yes | QMessageBox::No,
    QMessageBox::Yes))
    {
    //继续
    ui->zbmLineEdit->setText(_callbackInfo["goods_commonid"].toString());
    ui->txmLineEdit->setText(_callbackInfo["goods_serial"].toString());
    ui->nameLineEdit->setText(_callbackInfo["goods_name"].toString());
    ui->kcLineEdit->setText(_callbackInfo["goods_storage"].toString());
    ui->inputLineEdit->setText("");
    ui->inkcLineEdit->setFocus();
    this->inputkcs();
    }
    else
    {
    //no
    ui->inputLineEdit->setText("");
    ui->inputLineEdit->setFocus();
    }
    }
    }
    }
    else
    {
    this->showMsgBox(tr("网络连接超时!"));
    this->setEnabled(true);
    }
    }

    void MainDialog::inputkc()
    {
    QString repertory = ui->inkcLineEdit->text();
    if(repertory == "")
    {
    this->showMsgBox(tr("录入库存不能为空"));
    }
    else
    {
    state = 50;
    int i = goodsListModel->rowCount();
    QString s = QString::number(i+1,10);
    goodsListModel->setItem(i, 0, new QStandardItem(s));
    goodsListModel->setItem(i, 1, new QStandardItem(ui->zbmLineEdit->text()));
    goodsListModel->setItem(i, 2, new QStandardItem(ui->txmLineEdit->text()));
    goodsListModel->setItem(i, 3, new QStandardItem(ui->nameLineEdit->text()));
    goodsListModel->setItem(i, 4, new QStandardItem(ui->kcLineEdit->text()));
    goodsListModel->setItem(i, 5, new QStandardItem(ui->inkcLineEdit->text()));
    goodsListModel->setItem(i, 6, new QStandardItem(QString::number(state)));
    ui->tableView->selectRow(i);

        for(int j=0;j<goodsListModel->rowCount();++j)
        {
            QVariantMap oneMap;
            if(goodsListModel->index(j,6).data().toInt()== state)
            {
                oneMap["goods_commonid"] = goodsListModel->index(j,1).data().toString();
                oneMap["goods_nums"] = goodsListModel->index(j,5).data().toString();
                oneMap["seller_name"] = GlobalVariable::pcName;
                orderinfo[QString::number(j)] = oneMap;
            }
        }
        this->setupdate();
    }
    

    }

    void MainDialog::inputkcs()
    {
    QString repertory = ui->inkcLineEdit->text();
    if(repertory == "")
    {
    this->showMsgBox(tr("录入库存不能为空"));
    }
    else
    {
    QString pcname = GlobalVariable::pcName;
    if(name == pcname)
    {
    for(int i=0;irowCount();++i)
    {
    if(ui->inkcLineEdit->text()==goodsListModel->index(i,1).data().toString())
    {
    double ikc=goodsListModel->index(i,5).data().toDouble();
    double num = repertory.toDouble()+ikc;
    goodsListModel->setItem(i, 5, new QStandardItem(QString::number(num)));
    goodsListModel->setItem(i, 6, new QStandardItem("50"));
    }
    }
    }

            QList<QVariant> oneList;
              oneList.append("goods_commonid="+ui->zbmLineEdit->text());
              oneList.append("goods_nums="+ui->inkcLineEdit->text());
              oneList.append("seller_name="+name);
              orderinfo["orderinfo"] = oneList;
    
        this->setupdate();
    }
    

    }

    void MainDialog::setupdate()
    {
    QJsonDocument json = QJsonDocument::fromVariant(QVariant(orderinfo));

    netWorkCon *net = new netWorkCon(this);
    QList paramList;
    QByteArray byte_array = json.toJson(QJsonDocument::Compact);
    QString jsonstr(byte_array);
    //qDebug() << jsonstr;
    //url
    paramList.append("order_info="+jsonstr+"&");
    net->conectNet(url,paramList);
    connect(net,&netWorkCon::connectFinished,this,&MainDialog::updatefinished);
    }

    void MainDialog::updatefinished(bool flag, QJsonDocument jsonResult)
    {
    if(flag)
    {
    if(jsonResult.isEmpty())
    {
    this->showMsgBox(tr("上传失败"));
    for(int j=0;jrowCount();++j)
    {
    if( goodsListModel->index(j,1).data().toString()== orderinfo["goods_commonid"].toString())
    {
    state = 0;
    goodsListModel->setItem(j, 6, new QStandardItem(QString::number(state)));
    ui->tableView->selectRow(j);
    this->clearAll();
    }
    }
    }
    else{
    QList commonList = jsonResult.toVariant().toList();
    for(int j=0;jrowCount();++j)
    {
    for(int i=0;i {
    if( goodsListModel->index(j,1).data().toString()==commonList.at(i).toString())
    {
    state = 100;
    goodsListModel->setItem(j, 6, new QStandardItem(QString::number(state)));
    ui->tableView->selectRow(j);
    this->clearAll();
    }
    }

            }
        }
    }
    else{
    
        this->showMsgBox(tr("网络连接超时!"));
        this->setEnabled(true);
        for(int j=0;j<goodsListModel->rowCount();++j)
        {
            if( goodsListModel->index(j,1).data().toString()== orderinfo["goods_commonid"].toString())
            {
                //state = 0;
                goodsListModel->setItem(j, 6, new QStandardItem("0"));
                ui->tableView->selectRow(j);
                this->clearAll();
            }
        }
    }
    

    }

    void MainDialog::clearAll()
    {
    ui->zbmLineEdit->clear();
    ui->txmLineEdit->clear();
    ui->nameLineEdit->clear();
    ui->kcLineEdit->clear();
    ui->inkcLineEdit->clear();
    ui->inputLineEdit->setFocus();
    }

    这是代码,里面我给删了三句,但不影响看,请大神看看是哪里出了问题

    点赞 评论 复制链接分享
  • yhm163email yhm163email 2016-05-13 06:47

    #include "maindialog.h"
    #include "ui_maindialog.h"
    #include "tools/globalvariable.h"

    MainDialog::MainDialog(QWidget *parent) :
    BasicDialog(parent),
    ui(new Ui::MainDialog)
    {
    this->setWindowFlags (Qt::FramelessWindowHint| Qt::WindowStaysOnTopHint);
    ui->setupUi(this);
    this->getGoods();
    this->init();
    }

    void MainDialog::init()
    {
    msgBox->raise();
    ui->staffLabel->setText(GlobalVariable::pcName);
    //初始化按钮
    this->initButton();
    this->initTableView();
    state = 0;
    }

    void MainDialog::initEdit()
    {

    ui->inputLineEdit->setFocus();
    QRegExp regExp("[0-9,.]{0,18}");
    ui->inputLineEdit->setValidator(new QRegExpValidator(regExp,this));
    

    }

    void MainDialog::initButton()
    {
    quitBt = new quitButton(this);
    quitBt->move(989,0);
    quitBt->setAutoDefault(false);
    connect(quitBt,&quitButton::clicked,this,&MainDialog::showWarning);
    }

    void MainDialog::initTableView()
    {
    goodsListModel = new MyStandardModel;
    goodsListModel->setHorizontalHeaderItem(0, new QStandardItem(QObject::tr("")));
    goodsListModel->setHorizontalHeaderItem(1, new QStandardItem(QObject::tr("商品自编码")));
    goodsListModel->setHorizontalHeaderItem(2, new QStandardItem(QObject::tr("商品条码")));
    goodsListModel->setHorizontalHeaderItem(3, new QStandardItem(QObject::tr("商品名称")));
    goodsListModel->setHorizontalHeaderItem(4, new QStandardItem(QObject::tr("当前数量")));
    goodsListModel->setHorizontalHeaderItem(5, new QStandardItem(QObject::tr("录入数量")));
    goodsListModel->setHorizontalHeaderItem(6, new QStandardItem(QObject::tr("状态")));

    ui->tableView->setModel(goodsListModel);
    ui->tableView->setColumnWidth(0,40);
    ui->tableView->setColumnWidth(1,120);
    ui->tableView->setColumnWidth(2,160);
    ui->tableView->setColumnWidth(3,300);
    ui->tableView->setColumnWidth(4,90);
    ui->tableView->setColumnWidth(5,90);
    ui->tableView->setColumnWidth(6,90);
    
    ui->tableView->hideColumn(10);
    ui->tableView->verticalHeader()->hide();
    ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    
    QFont font;
    font.setPointSize(10);
    ui->tableView->setStyleSheet("QTableView::item::selected{color:white;background:#337cc9}");
    ui->tableView->horizontalHeader()->setStyleSheet("QTableView::selected{background:#ffffff;}");
    ui->tableView->setFont(font);
    ui->tableView->horizontalHeader()->setMinimumHeight(42);
    ui->tableView->verticalHeader()->setDefaultSectionSize(42);
    

    }

    void MainDialog::getGoods()
    {
    netWorkCon *net = new netWorkCon(this);
    QList paramList;
    //url
    paramList.append("seller_name ="+GlobalVariable::pcName);
    net->conectNet(url,paramList);
    connect(net,&netWorkCon::connectFinished,this,&MainDialog::getGoodsFinished);
    }

    void MainDialog::getGoodsFinished(bool flag, QJsonDocument jsonResult)
    {
    if(flag)
    {
    if(jsonResult.isEmpty())
    {
    QMessageBox::information(this,"提示","尚未获取到任何数据,如果是第一次输入,请忽略,如果有历史数据,请联系管理员",QMessageBox::Yes);
    }
    else
    {
    QVariantMap result = jsonResult.toVariant().toMap();
    state = 100;
    for(int i=0;i {
    goodsListModel->setItem(i, 0, new QStandardItem(QString::number(i+1)));
    goodsListModel->setItem(i, 1, new QStandardItem(result["goods_commonid"].toString()));
    goodsListModel->setItem(i, 2, new QStandardItem(result["goods_serial"].toString()));
    goodsListModel->setItem(i, 3, new QStandardItem(result["goods_name"].toString()));
    goodsListModel->setItem(i, 4, new QStandardItem(result["goods_begin"].toString()));
    goodsListModel->setItem(i, 5, new QStandardItem(result["goods_storage"].toString()));
    goodsListModel->setItem(i, 6, new QStandardItem(state));
    }

        }
        connect(ui->inputLineEdit,&QLineEdit::returnPressed,this,&MainDialog::goodsSearch);
    }
    else
    {
        this->showMsgBox(tr("网络连接超时!"));
        this->setEnabled(true);
    }
    

    }

    void MainDialog::goodsSearch()
    {
    QString goods_ma = ui->inputLineEdit->text();
    if(goods_ma=="")
    {
    this->showMsgBox(tr("输入条形码或自编码不能为空!"));
    }
    else
    {
    netWorkCon *net = new netWorkCon(this);
    QList paramList;
    //url
    paramList.append("goods_ma="+goods_ma);
    net->conectNet(url,paramList);
    connect(net,&netWorkCon::connectFinished,this,&MainDialog::goodsSearchFinished);
    }
    }

    void MainDialog::goodsSearchFinished(bool flag, QJsonDocument jsonResult)
    {
    if(flag)
    {
    if(jsonResult.isEmpty())
    {
    this->showMsgBox(tr("商品不存在"));
    ui->inputLineEdit->clear();
    ui->inputLineEdit->setFocus();
    }
    else
    {
    QVariantMap _callbackInfo = jsonResult.toVariant().toMap();
    if(_callbackInfo["state"].toInt()==0)
    {
    ui->zbmLineEdit->setText(_callbackInfo["goods_commonid"].toString());
    ui->txmLineEdit->setText(_callbackInfo["goods_serial"].toString());
    ui->nameLineEdit->setText(_callbackInfo["goods_name"].toString());
    ui->kcLineEdit->setText(_callbackInfo["goods_storage"].toString());
    ui->inputLineEdit->setText("");
    ui->inkcLineEdit->setFocus();
    connect(ui->inkcLineEdit,&QLineEdit::returnPressed,this,&MainDialog::inputkc);
    }
    else if(_callbackInfo["state"].toInt()==-1)
    {
    this->showMsgBox(tr("条码错误"));
    ui->inputLineEdit->setText("");
    ui->inputLineEdit->setFocus();
    }
    else if(_callbackInfo["state"].toInt()==2)
    {
    name = _callbackInfo["seller_name"].toString();
    //qDebug()< QString str = name + "已盘存过此商品,是否继续?";
    if(QMessageBox::Yes == QMessageBox::question(this,
    "Question",
    str,
    QMessageBox::Yes | QMessageBox::No,
    QMessageBox::Yes))
    {
    //继续
    ui->zbmLineEdit->setText(_callbackInfo["goods_commonid"].toString());
    ui->txmLineEdit->setText(_callbackInfo["goods_serial"].toString());
    ui->nameLineEdit->setText(_callbackInfo["goods_name"].toString());
    ui->kcLineEdit->setText(_callbackInfo["goods_storage"].toString());
    ui->inputLineEdit->setText("");
    ui->inkcLineEdit->setFocus();
    this->inputkcs();
    }
    else
    {
    //no
    ui->inputLineEdit->setText("");
    ui->inputLineEdit->setFocus();
    }
    }
    }
    }
    else
    {
    this->showMsgBox(tr("网络连接超时!"));
    this->setEnabled(true);
    }
    }

    void MainDialog::inputkc()
    {
    QString repertory = ui->inkcLineEdit->text();
    if(repertory == "")
    {
    this->showMsgBox(tr("录入库存不能为空"));
    }
    else
    {
    state = 50;
    int i = goodsListModel->rowCount();
    QString s = QString::number(i+1,10);
    goodsListModel->setItem(i, 0, new QStandardItem(s));
    goodsListModel->setItem(i, 1, new QStandardItem(ui->zbmLineEdit->text()));
    goodsListModel->setItem(i, 2, new QStandardItem(ui->txmLineEdit->text()));
    goodsListModel->setItem(i, 3, new QStandardItem(ui->nameLineEdit->text()));
    goodsListModel->setItem(i, 4, new QStandardItem(ui->kcLineEdit->text()));
    goodsListModel->setItem(i, 5, new QStandardItem(ui->inkcLineEdit->text()));
    goodsListModel->setItem(i, 6, new QStandardItem(QString::number(state)));
    ui->tableView->selectRow(i);

        for(int j=0;j<goodsListModel->rowCount();++j)
        {
            QVariantMap oneMap;
            if(goodsListModel->index(j,6).data().toInt()== state)
            {
                oneMap["goods_commonid"] = goodsListModel->index(j,1).data().toString();
                oneMap["goods_nums"] = goodsListModel->index(j,5).data().toString();
                oneMap["seller_name"] = GlobalVariable::pcName;
                orderinfo[QString::number(j)] = oneMap;
            }
        }
        this->setupdate();
    }
    

    }

    void MainDialog::inputkcs()
    {
    QString repertory = ui->inkcLineEdit->text();
    if(repertory == "")
    {
    this->showMsgBox(tr("录入库存不能为空"));
    }
    else
    {
    QString pcname = GlobalVariable::pcName;
    if(name == pcname)
    {
    for(int i=0;irowCount();++i)
    {
    if(ui->inkcLineEdit->text()==goodsListModel->index(i,1).data().toString())
    {
    double ikc=goodsListModel->index(i,5).data().toDouble();
    double num = repertory.toDouble()+ikc;
    goodsListModel->setItem(i, 5, new QStandardItem(QString::number(num)));
    goodsListModel->setItem(i, 6, new QStandardItem("50"));
    }
    }
    }

            QList<QVariant> oneList;
              oneList.append("goods_commonid="+ui->zbmLineEdit->text());
              oneList.append("goods_nums="+ui->inkcLineEdit->text());
              oneList.append("seller_name="+name);
              orderinfo["orderinfo"] = oneList;
    
        this->setupdate();
    }
    

    }

    void MainDialog::setupdate()
    {
    QJsonDocument json = QJsonDocument::fromVariant(QVariant(orderinfo));

    netWorkCon *net = new netWorkCon(this);
    QList paramList;
    QByteArray byte_array = json.toJson(QJsonDocument::Compact);
    QString jsonstr(byte_array);
    //qDebug() << jsonstr;
    //url
    paramList.append("order_info="+jsonstr+"&");
    net->conectNet(url,paramList);
    connect(net,&netWorkCon::connectFinished,this,&MainDialog::updatefinished);
    }

    void MainDialog::updatefinished(bool flag, QJsonDocument jsonResult)
    {
    if(flag)
    {
    if(jsonResult.isEmpty())
    {
    this->showMsgBox(tr("上传失败"));
    for(int j=0;jrowCount();++j)
    {
    if( goodsListModel->index(j,1).data().toString()== orderinfo["goods_commonid"].toString())
    {
    state = 0;
    goodsListModel->setItem(j, 6, new QStandardItem(QString::number(state)));
    ui->tableView->selectRow(j);
    this->clearAll();
    }
    }
    }
    else{
    QList commonList = jsonResult.toVariant().toList();
    for(int j=0;jrowCount();++j)
    {
    for(int i=0;i {
    if( goodsListModel->index(j,1).data().toString()==commonList.at(i).toString())
    {
    state = 100;
    goodsListModel->setItem(j, 6, new QStandardItem(QString::number(state)));
    ui->tableView->selectRow(j);
    this->clearAll();
    }
    }

            }
        }
    }
    else{
    
        this->showMsgBox(tr("网络连接超时!"));
        this->setEnabled(true);
        for(int j=0;j<goodsListModel->rowCount();++j)
        {
            if( goodsListModel->index(j,1).data().toString()== orderinfo["goods_commonid"].toString())
            {
                //state = 0;
                goodsListModel->setItem(j, 6, new QStandardItem("0"));
                ui->tableView->selectRow(j);
                this->clearAll();
            }
        }
    }
    

    }

    void MainDialog::clearAll()
    {
    ui->zbmLineEdit->clear();
    ui->txmLineEdit->clear();
    ui->nameLineEdit->clear();
    ui->kcLineEdit->clear();
    ui->inkcLineEdit->clear();
    ui->inputLineEdit->setFocus();
    }

    这是代码,里面我给删了三句,但不影响看,请大神看看是哪里出了问题

    点赞 评论 复制链接分享

相关推荐