void FormPZLR::on_tablePZ_itemClicked(QTableWidgetItem *item) { //1、记录旧的单元格内容 old_text = item->text(); if (item->text()=="" && item->column()==2){ item->setText(ZYXX); } itemR=item->row(); itemC=item->column(); ui->txtInput->resize(ui->tablePZ->columnWidth(0),48); int colx=40; for (int i=0;i<item->column();i++) { colx+=ui->tablePZ->columnWidth(i); ui->txtInput->resize(ui->tablePZ->columnWidth(i+1),48); } int coly=48; for (int i=0;i<item->row();i++) { coly+=48; } int GD=ui->tablePZ->verticalScrollBar()->value(); int maxGD=ui->tablePZ->verticalScrollBar()->maximum(); if (GD<maxGD){ GD++; } if (GD>=1) { coly=coly-(GD-1)*48; } int x=ui->tablePZ->x()+colx; int y=ui->tablePZ->y()+coly; ui->txtInput->move(x,y); ui->treeWidget->move(x+ui->txtInput->width(),y); ui->txtInput->setText(item->text()); ui->txtInput->setVisible(true); ui->txtInput->selectAll(); ui->txtInput->setFocus(Qt::OtherFocusReason); }
记录一段代码
2021-01-23 22:22:15
阅读 3014 次
评论 0 条
发表评论