November 10, 2011

mzimmers mzimmers
Ant Farmer
524 posts

[solved] copying/renaming a project

Page  
1

Hi –

Before I go off and clobber anything, I thought I’d ask here: is there a guide (or cheat sheet or anything) to renaming projects and/or copying them? I want to use one project as the basis for another. This will entail modifying pathnames, names of of the finished program and so on.

I already know that I’ll need to change the build directory in Projects->Build. How do I go about renaming the executable…is that done by renaming the .pro file?

Thanks.

17 replies

November 10, 2011

Eddy Eddy
Area 51 Engineer
1295 posts

How do I go about renaming the executable…is that done by renaming the .pro file?

Have a look at target [doc.qt.nokia.com]

 Signature 

Qt Certified Specialist
Qt Ambassador

November 10, 2011

mzimmers mzimmers
Ant Farmer
524 posts

The “target” entry in my profile is blank. So, I guess it picked it up from the directory name, huh?

Assuming I’m right, can I change it without putting an entry in the .pro file?

November 11, 2011

Eddy Eddy
Area 51 Engineer
1295 posts

Can you elaborate on your specific use case?
Why is it you don’t like to use the pro file for that?

 Signature 

Qt Certified Specialist
Qt Ambassador

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

Oh, I don’t necessarily mind using the .pro file. It’s just that since it was apparently built without an entry there, I was wondering whether I could preserve the way that the executable was named. Mostly for academic curiosity.

Anyway, if I go ahead and change the .pro file, and the build directory, is that it? Or is there more that I’ll need to do? There are no absolute pathnames in any of my code.

November 11, 2011

Volker Volker
Robot Herder
5428 posts

In case the TARGET variable is empty, the name of the executable is the name of your .pro file without the .pro extension (and maybe appended with .app on the mac).

If you set the TARGET variable, that will be the name of the executable.

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

Thanks, Volker. So…if I rename the .pro file, and change the entry for the build directory, am I covered?

November 11, 2011

Volker Volker
Robot Herder
5428 posts

That should basically work, yes.

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

OK, thanks, guys.

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

Actually, two follow-up questions:

1. am I correct in assuming I should rename the .pro.user file, too?
2. what’s the best way to get Creator to make me a build directory? Or will this happen for me automatically, like when I create a new project?

Thanks.

November 11, 2011

Volker Volker
Robot Herder
5428 posts

1. I recommend deleting the .pro.user file – it contains absolute paths that may clutter with the original paths of your copy.

2. If you import a project, select “shadow build” in the wizard that pops up. Creator and/or qmake will create any missing build directories.

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

Regarding #2…I just copied the entire project file structure. Should I not have done that? I can’t import that way.

November 11, 2011

Volker Volker
Robot Herder
5428 posts

Oh, no problem with that. I do that regularly :-) Just make sure to not re-use the .pro.user file. If you open the .pro files in Creator the project wizards start over. This ensures that your paths are not messed up with the old project (original copy).

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

OK, so maybe a recommended procedure (if it’s not documented elsewhere, this might help someone later) is:

1. copy the directory structure.
2. delete the .pro.user file
3. change the build directory in Projects->Build
4. modify the name of the .pro file if desired (or edit the TARGET tag in the .pro file)
5. run qmake

Did I leave anything out?

November 11, 2011

Volker Volker
Robot Herder
5428 posts

Sounds good to me.

November 11, 2011

mzimmers mzimmers
Ant Farmer
524 posts

Excellent…thanks again.

Page  
1

  ‹‹ Various usability problems with Creator 2.3.1 on OSX      Need feature auto-completion after one character in Qt Creator ››

You must log in to post a reply. Not a member yet? Register here!