int rowCount=UI. DetectingPointsTable - & gt; RowCount ();//the number of rows
UI. DetectingPointsTable - & gt; InsertRow (rowCount);
UI. DetectingPointsTable - & gt; SetItem (0, 0, new QTableWidgetItem (QStringLiteral (" K ") + QString: : number (50) + ", "+ QString: : number (50)));
UI. DetectingPointsTable - & gt; SetItem (0, 1, new QTableWidgetItem (R: 0 G: 0 B: "0"));
UI. DetectingPointsTable - & gt; SetItem (0, 2, new QTableWidgetItem (QString: : number (0) + QStringLiteral (", ")));
UI. DetectingPointsTable - & gt; InsertRow (rowCount);
UI. DetectingPointsTable - & gt; SetItem (1, 0, new QTableWidgetItem (QStringLiteral (" J: ") + QString: : number (100) + ", "+ QString: : number (100)));
UI. DetectingPointsTable - & gt; SetItem (1, 1, new QTableWidgetItem (R: 0 G: 0 B: "0"));
UI. DetectingPointsTable - & gt; SetItem (1, 2, new QTableWidgetItem (QString: : number (0) + QStringLiteral (", ")));
CodePudding user response:
I found that no matter how much to add, all show only the last line of data
Int the rowCount=UI. DetectingPointsTable - & gt; RowCount ();//the number of rows
UI. DetectingPointsTable - & gt; InsertRow (rowCount);
UI. DetectingPointsTable - & gt; SetItem (0, 0, new QTableWidgetItem (QStringLiteral (" K ") + QString: : number (50) + ", "+ QString: : number (50)));
UI. DetectingPointsTable - & gt; SetItem (0, 1, new QTableWidgetItem (R: 0 G: 0 B: "0"));
UI. DetectingPointsTable - & gt; SetItem (0, 2, new QTableWidgetItem (QString: : number (0) + QStringLiteral (" ℃ ")));
UI. DetectingPointsTable - & gt; InsertRow (rowCount);
UI. DetectingPointsTable - & gt; SetItem (1, 0, new QTableWidgetItem (QStringLiteral (" J: ") + QString: : number (100) + ", "+ QString: : number (100)));
UI. DetectingPointsTable - & gt; SetItem (1, 1, new QTableWidgetItem (R: 0 G: 0 B: "0"));
UI. DetectingPointsTable - & gt; SetItem (1, 2, new QTableWidgetItem (QString: : number (0) + QStringLiteral (" ℃ ")));
.
UI. DetectingPointsTable - & gt; InsertRow (rowCount);
UI. DetectingPointsTable - & gt; SetItem (20, 0, new QTableWidgetItem (QStringLiteral (" U ") + QString: : number (100) + ", "+ QString: : number (100)));
UI. DetectingPointsTable - & gt; SetItem (20 to 1, the new QTableWidgetItem (R: 0 G: 0 B: "0"));
UI. DetectingPointsTable - & gt; SetItem (20, 2, new QTableWidgetItem (QString: : number (0) + QStringLiteral (" ℃ ")));
UI. DetectingPointsTable - & gt; InsertRow (rowCount);
UI. DetectingPointsTable - & gt; SetItem (21, 0, new QTableWidgetItem (QStringLiteral (" V ") + QString: : number (100) + ", "+ QString: : number (100)));
UI. DetectingPointsTable - & gt; SetItem (21, 1, new QTableWidgetItem (R: 0 G: 0 B: "0"));
UI. DetectingPointsTable - & gt; SetItem (21, 2, new QTableWidgetItem (QString: : number (0) + QStringLiteral (" ℃ ")));
CodePudding user response:
The beginning is an empty table, then the rowCount=0Then you insertRow (0), insert the line 1, set the line item 1
Then you insertRow (0), and insert the line 1, replacing the original line 1 to line 2, and then you take line 2 (line 1) of the original item all reset again
CodePudding user response:
Every time you put a line, the rowCount to + +, you always in the first line plug, you forever is the first time you set the line