-1

I wrote console Qt application. I'd like to copy file from directory, where is my exe file.

m_Path = QCoreApplication::applicationDirPath() + "\\g.aux.xml";
QFile::copy(m_Path,PathNew);

This code excellent works, when I debug my application. But when I copy my .exe file to another directory it does not work.

Please tell me, how fix it.

UPD: I think I found the answer I need to use QDir::currentPath()

Get current working directory in a Qt application

Community
  • 1
  • 1
novicegis
  • 519
  • 3
  • 5
  • 13
  • 1
    What does "does not work" mean. How does it fail. Please describe the problem completely. Please describe the precise layout of files. – David Heffernan Aug 26 '13 at 13:42

1 Answers1

0

You're most likely missing .dll files.

Copying only the .exe file is not enough for Qt applications - you must make sure the necessary dynamic libraries are in the same directory as the .exe. In your case, copying QtCore4.dll or Qt5Core.dll from your compiler's directory should do, but you'll want to read this page for more details in the future.

Also, in the future, please describe your problem with more detail.

More Axes
  • 249
  • 3
  • 12
  • I deploy this application (it works). This application creates world files. But it does not copy files. The question is "How to set application path?" – novicegis Aug 26 '13 at 13:37
  • In the past files was situated on the disk C. The directory was C:\bin\... And I always copy this files before working. Now I do not want to copy this files yourself. – novicegis Aug 26 '13 at 13:41
  • Sorry, I thought this was a deployment issue. In this case, you'll probably want to check if `applicationDirPath()` returns the correct directory, and if `PathNew` points where it's supposed to. You might have to convert backslashes to forward slashes, or the other way around. That's all I know. – More Axes Aug 26 '13 at 13:45