returning empty std::string when converting a QString with a path to an std::string using toStdString
-
Please don't pictures but text - so we can try out the code directly.
You forgot to flush the output buffer -> see std::endl or std::flush
-
@Christian-Ehrlicher the text is recieved from QML from a FolderDialog
then converted from URL to QString -
@UbiMiles Did you actually read my answer on why it does not print something?
-
@Christian-Ehrlicher as for flushing I am not intending to output the string but using it with an external SDK, the bug caused a weird exception in the disassembler
and I found out it is because the string is empty -
@UbiMiles The string is not empty. Please provide a minimal, compilable example of your real code. Your code above does not output anything because (third time) you forgot to flush the output buffer.
-
@Christian-Ehrlicher
when passing the standard library string to a function it causes a runtime error in the disassembler
do you have any idea what may be causing such issue -
@UbiMiles said in returning empty std::string when converting a QString with a path to an std::string using toStdString:
when passing the standard library string to a function it causes a runtime error in the disassembler
Maybe you mix debug and release dlls which you're not allowed to do so on Windows.
No more ideas without any code / minimal compilable example. -
@Christian-Ehrlicher
I think the porblem has to do with me appending the date and time to my stringsampleName.append(QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss"));
-
@UbiMiles said in returning empty std::string when converting a QString with a path to an std::string using toStdString:
@Christian-Ehrlicher
I think the porblem has to do with me appending the date and time to my stringsampleName.append(QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss"));
on windows, a colon (
:
)is not a valid character for filenames and/or a path
annotation,
:
can and in fact is part of every windows (full) path, but its reserved for the drive letter association -