初学qt——提示窗体

带选择的窗体

QMessageBox::StandardButton rb = QMessageBox::critical(NULL, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("确定删除吗?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
//下面是判断选择后的操作
    if(rb == QMessageBox::Yes) 
    { 
        QPushButton *btn = (QPushButton *) sender();
        QString row= btn->property("row").toString();
        QString id = btn->property("ids").toString();
        Model->removeRow(0);
        QString sql="delete from syzbInfo where id=:id";
        QSqlQuery query;
        query.prepare(sql);
        query.bindValue(":id",id);
        if(query.exec()){
            ui.tableView_syzb->setRowHidden(row.toInt(),true);
            getSyzbData(Data::id_cards);
        }
    }

只有确定按钮的消息窗体

QMessageBox::about(NULL, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("添加失败"));
posted @ 2016-07-27 17:29  林十八  阅读(114)  评论(0编辑  收藏  举报