title: pyqt QFileDialog.getOpenFileName() get path of the directory of the file
body: <p>I'm searching for a way to get the path of the directory of the file that I have chosen by <code>QFileDialog.getOpenFileName()</code>.
  I know that you can access it by <code>os.path.dirname(os.path.realpath(filename)</code>, but I'm searching for a better way because I need to work in this directory.
  I don't really understand why you can access the file by <code>open(filename, 'r')</code> though your current working directory (when typing <code>print(os.getcwd())</code> is not the directory of the file.
  Maybe there is a way by accessing something like the current working directory of the Qt.Application, but I had no success..</p>
  
  <p>Also I have functions where you need <code>arg1 = directory</code> and <code>arg2 = filename1</code> (in the directory) as arguments. Funnily enough they suddenly seem to work with just(!) <code>arg1 = 'C:'</code> as directory and <code>arg2 = filename2</code> when <code>filename2</code> is the file I've accessed by <code>QFileDialog.getOpenFileName()</code>.</p>
  
  <p>I'm happy about any explanation!</p>