1

I am using a dialog to get a filename path. I have managed to get it running and saving it to a local variable but Qt does not return the file path written in the pythonic way.

My cood is simple as that:

    u = str( QtGui.QFileDialog.getOpenFileName())

but it returns me something like this:

C:/Artur/PC/Trabalho Darlan/

instead

C:\Artur\PC\Trabalho Darlan\

I have tried to replace / for \ with no success. What should I do?

1

1 Answer 1

2

Qt returns all paths using / as the separator.

You can use the abspath() method:

os.path.abspath(u)

Or the toNativeSeparators method provided by Qt's QDir:

QDir.toNativeSeparators(u)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.