void mainWnd::distance(){ double x, y, tmp, firstPoint=1, secondPoint=2; QTableWidgetItem *item=new QTableWidgetItem; x=tableWidget->item(firstPoint, 1)-tableWidget->item(secondPoint, 1); y=tableWidget->item(firstPoint, 2)-tableWidget->item(secondPoint, 2); tmp=(x*x)+(y*y); item->setData(0, tmp); emit tableWidget_2->setItem(firstPoint, secondPoint, item);}
C++ (Qt)void mainWnd::distance(){ double x, y, tmp, firstPoint=1, secondPoint=2; QTableWidgetItem *item=new QTableWidgetItem; x=tableWidget->item(firstPoint, 1)-tableWidget->item(secondPoint, 1); y=tableWidget->item(firstPoint, 2)-tableWidget->item(secondPoint, 2); tmp=(x*x)+(y*y); QVariant tableData; item->setData(Qt::EditRole, tableData.setValue(tmp)); emit tableWidget_2->setItem(firstPoint, secondPoint, item);}
item->setData(Qt::EditRole, tableData.setValue(tmp));
void QTreeWidgetItem::setData ( int column, int role, const QVariant & value )
void QTableWidgetItem::setData ( int role, const QVariant & value )
QVariant tableData(tmp);item->setData(Qt::EditRole, tableData);
void mainWnd::distance(){ int firstPoint=0, secondPoint=0; QTableWidgetItem *x=new QTableWidgetItem; x=tableWidget->takeItem(0, 0); tableWidget_2->setItem(firstPoint, secondPoint, x);}
C++ (Qt)x = tableWidget->item(firstPoint, 1).data(Qt::DisplayRole).toDouble() - tableWidget->item(secondPoint, 1).data(Qt::DisplayRole).toDouble(); y = tableWidget->item(firstPoint, 2).data(Qt::DisplayRole).toDouble() - tableWidget->item(secondPoint, 2).data(Qt::DisplayRole).toDouble();tmp = (x * x) + (y * y);QVariant tableData(tmp);item->setData(Qt::EditRole, tableData);
C++ (Qt)x = tableWidget->item();tableWidget_2->setItem(firstPoint, secondPoint, x->clone());
x = tableWidget->item(firstPoint, 0)->data(Qt::DisplayRole).toDouble() - tableWidget->item(secondPoint, 0)->data(Qt::DisplayRole).toDouble(); y = tableWidget->item(firstPoint, 1)->data(Qt::DisplayRole).toDouble() - tableWidget->item(secondPoint, 1)->data(Qt::DisplayRole).toDouble();