Solved Add hash function to saving in csv
-
hi
you just need to call like before
QString CityName = hash[value];
so u need the same hash here.
U can either make a new one here.
(reading 40 values is no big deal)
or re-arrange the code so this function/class can also use the existing hash.QString CityName = hash[value];
value is
ui->tableView_3->model()->data(ui->tableView_3->model()->index(r, c), Qt::DisplayRole).toString()
when "c" is the correct column. ( u must use if to test for that) -
@mrjj said:
or re-arrange the code so this function/class can also use the existing hash.
QString CityName = hash[value];
value is
ui->tableView_3->model()->data(ui->tableView_3->model()->index(r, c), Qt::DisplayRole).toString()
when "c" is the correct column. ( u must use if to test for that)I think I don't understand you well. Why I can't just paste that code with little transformation?(if it need to use) .
ui->tableView_2->setItemDelegateForColumn(3, new MyDelegate(this));
And do you mean that I should write that? But it won't work( or not)?
QString CityName = hash[ ui->tableView_3->model()->data(ui->tableView_3->model()->index(r, c), Qt::DisplayRole).toString()]
-
- Why I can't just paste that code with little transformation
Because the delegate replace the text (data) when showing it.
Now you are reading data directly to save it and
ui->tableView_3->model()->data return the original data, there is no delegate in between to
translate.
So you must do it. (again)
And yes like you show, but ONLY when c is the COL you want to convert.
and then write out cityname and not directly from data.
- Why I can't just paste that code with little transformation
-
@mrjj I really don't understand the method for solving that problem.
This is the project with all functions: saving in csv(after clicking on the button) and the hash function(thanks :D)
http://rghost.ru/62XsMLmDk
Can you watch what I should to change? My skills are better now, but insufficiently -
You must use the hash again,
so i moved the code into function.
that way we can also create a hash when exporting.https://www.dropbox.com/s/6oqbcvcz006kzeh/myfristview_hash3.zip?dl=0
Note I copy the hash, so if u had 10000000 items, it would not be the way to do it.
-
@mrjj Thank you, now I understand.
-
@mrjj I found the bag. It is changing ALL columns, how to do it only for one column?
I have edited the code on that:QString value = uimodel->data(uimodel->index(r, 3), Qt::DisplayRole).toString();
but then it will duplicate that column to all another.
-
@ro12man3
oh the test had only one COL so didn't checkyou do
for( int c = 0; c < ui->tableView->horizontalHeader()->count()
...
so you should only do it when c == the_right_colyou could
... if (c == 3) strList << "\"" + mapped + "\""; else strList << "\"" + value + "\"";
-
@mrjj yeeeep! it's working! thank you!
-
@ro12man3 said:
super :)