该功能是从文本文件中读取硬盘分区。该函数工作正常,但是当我想在分区布局更改后重新加载表时,它会添加与之前显示的数量相同的空白行,并开始在单词之后写入数据行。
void PartitionPage::processPartitions(QString line, int numberOfRows){
static int row = 0;
QStringList partitions = line.split(":");
qDebug() << numberOfRows;
//qDebug() << partitions.count();
if(partitionTable->rowCount() < (row + 1))
partitionTable->setRowCount(row + 1);
// we want to dispay first 7 columns only
//if(partitionTable->columnCount() < partitions.size())
// partitionTable->setColumnCount( partitions[0].size() );
// Set Header Label Texts Here
// set the columncount to 7 as we only want to display first 7 column
partitionTable->setColumnCount(7);
partitionTable->setColumnWidth(0, 120);
partitionTable->setColumnWidth(1, 120);
partitionTable->setColumnWidth(2, 120);
partitionTable->setColumnWidth(3, 120);
partitionTable->setColumnWidth(4, 120);
partitionTable->setColumnWidth(5, 120);
partitionTable->setColumnWidth(6, 120);
partitionTable->setHorizontalHeaderLabels(QString("Partition; Start Sector; End Sector; Total Sectors; Partition Size; Partition ID; File System").split(";"));
for( int column = 0; column < partitionTable->columnCount(); column++){
QTableWidgetItem *newItem = new QTableWidgetItem();
newItem->setText(partitions.at(column));
partitionTable->setItem(row, column, newItem);
newItem->setTextAlignment(Qt::AlignCenter);
}
row++;
partitionTable->setAlternatingRowColors(true);
partitionTable->setSelectionBehavior(QAbstractItemView::SelectRows);
}
空白行
答案 0 :(得分:0)
Qt在视图模型系统中有很多错误。你最搞笑。
可能的解决方案:
1)尝试使用另一个Qt版本。
2)尝试使用QTableView制作表并拥有“模型”(QAbstractTableModel的子节点)这不会是第一次简单。但可以提供帮助