QTableView加载数据

void VCAdmin::searchAllUser()
{
    strID_Index = "";
    if (NULL == vcManageDatabaseObj)
    {
        vc_admin_ui.label_msg->setText(QString::fromLocal8Bit("请连接数据库!"));
        return;
    }
    QSqlQuery query_sql = vcManageDatabaseObj->searchAllUser();

    admin_model->clear();
    int count_sr1 = 0;
    while (query_sql.next())
    {

        QString strID = query_sql.value(0).toString();
        QString strUSerName = query_sql.value(1).toString();
        QString strUserPWd = query_sql.value(2).toString();

        QString strRealName = query_sql.value(3).toString();
        QString strMobile = query_sql.value(4).toString();
        QString strCreator = query_sql.value(5).toString();
        QString strCreateDate = query_sql.value(6).toString();

        admin_model->setItem(count_sr1, 0, new QStandardItem(strID));
        admin_model->setItem(count_sr1, 1, new QStandardItem(strUSerName));
        admin_model->setItem(count_sr1, 2, new QStandardItem(strUserPWd));
        admin_model->setItem(count_sr1, 3, new QStandardItem(strRealName));

        admin_model->setItem(count_sr1, 4, new QStandardItem(strMobile));
        admin_model->setItem(count_sr1, 5, new QStandardItem(strCreator));
        admin_model->setItem(count_sr1, 6, new QStandardItem(strCreateDate));

        count_sr1++;
    }

    //设置数据
    setTableData();
}

 

转载于:https://www.cnblogs.com/herd/p/11586748.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值