Code: Alles auswählen
void open_data(QString pfad, QString filename, QTableWidget *table)
{
QFile *new_file = new QFile();
QDir::setCurrent(pfad);
new_file->setFileName(filename);
QTextStream t_str(new_file);
QStringList *QStrLst = new QStringList();
if (new_file->open(QIODevice::ReadOnly | QIODevice::Text) )
{
while(!t_str.atEnd() )
{
QString line = t_str.readLine();
QStrLst->push_back(line);
}
}
new_file->close();
QTableWidgetItem *T_item = new QTableWidgetItem();
for(int i = 0; i < QStrLst->size(); i++)
{
T_item->setText(QStrLst->at(i).section("\t", 2, 2) );
int row;
QString str_row = QStrLst->at(i).section("\t", 0, 0);
row = str_row.toInt();
int column;
QString str_column = QStrLst->at(i).section("\t", 1, 1);
column = str_column.toInt();
table->setItem(row, column, T_item);
}
}
Code: Alles auswählen
0 0 Typ:
0 1 A:
0 2 Ausruestung:
0 3 Punkte:
1 0 HQ:
6 0 Elite:
11 0 Standard:
19 0 Sturm:
24 0 Unterstuetzung:Code: Alles auswählen
std::cout<<"setze: "<<T_item->text().toStdString()<<" an: "<<row<<" "<<column<<std::endl;