char* chRead; QString isRead; //фаил загрузки примененных сейчас данных QString D_path = "C:/WORK/"; QString D_format = "bin"; isRead = dlg.getOpenFileName(this,trUtf8("Открываем ДАМПы RE"),D_path,trUtf8("DUMP(*.%1)").arg(D_format)); char* chRead2 = isRead.toAscii().data(); //перевод QString в char 

differs from

 char* chRead; chRead = "C:/Works/contr_glsso1/DUMP/SK0_20140305_192834_384.bin"; 

The result is different. I do not understand what the problem is - qDebug displays the same thing.

  chRead C:/Works/contr_glsso1/DUMP/SK0_20140305_192834_384.bin 

Closed due to the fact that off-topic participants Abyx , αλεχολυτ , user194374, Ivan Pshenitsyn , aleksandr barakin 27 Aug '16 at 9:33 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Abyx, αλεχολυτ, Community Spirit, Ivan Pshenitsyn, aleksandr barakin
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • I do not quite understand what you want to do, and what the problem is. What do you qDebug in qDebug ? Why do you assign chRead some value by hand? Try to make a minimum workable example and follow the principle: did - what do you want to get? - what got - user1056837

1 answer 1

Decided it was necessary to correctly translate into Char

 char* value_name = new char[255]; char* sometext=isRead.toAscii().data(); value_name = sometext; 

Here is the code that added.

But in a common bundle

 QFileDialog dlg(this); QString D_path = "C:/WORK/"; QString D_format = "bin"; isRead = dlg.getOpenFileName(this,trUtf8("Открываем ДАМПы RE"),D_path,trUtf8("DUMP(*.%1)").arg(D_format)); if(isRead.isEmpty()) { return; } qDebug()<< isRead; qDebug()<< "мы тут загружаем"; char* value_name = new char[255]; char* sometext=isRead.toAscii().data(); value_name = sometext;