Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. [solved] copying/renaming a project
QtWS25 Last Chance

[solved] copying/renaming a project

Scheduled Pinned Locked Moved Qt Creator and other tools
18 Posts 4 Posters 23.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mzimmers
    wrote on 10 Nov 2011, 22:15 last edited by
    #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.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      Eddy
      wrote on 10 Nov 2011, 22:39 last edited by
      #2

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

      Have a look at "target":http://doc.qt.nokia.com/4.7/qmake-variable-reference.html#target

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mzimmers
        wrote on 10 Nov 2011, 22:43 last edited by
        #3

        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?

        1 Reply Last reply
        0
        • E Offline
          E Offline
          Eddy
          wrote on 10 Nov 2011, 23:03 last edited by
          #4

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

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mzimmers
            wrote on 10 Nov 2011, 23:08 last edited by
            #5

            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.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on 10 Nov 2011, 23:39 last edited by
              #6

              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.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mzimmers
                wrote on 10 Nov 2011, 23:42 last edited by
                #7

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

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 10 Nov 2011, 23:44 last edited by
                  #8

                  That should basically work, yes.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mzimmers
                    wrote on 11 Nov 2011, 00:10 last edited by
                    #9

                    OK, thanks, guys.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mzimmers
                      wrote on 11 Nov 2011, 00:22 last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on 11 Nov 2011, 00:31 last edited by
                        #11
                        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.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mzimmers
                          wrote on 11 Nov 2011, 00:38 last edited by
                          #12

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

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on 11 Nov 2011, 00:44 last edited by
                            #13

                            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).

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              mzimmers
                              wrote on 11 Nov 2011, 00:49 last edited by
                              #14

                              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?

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on 11 Nov 2011, 00:50 last edited by
                                #15

                                Sounds good to me.

                                http://www.catb.org/~esr/faqs/smart-questions.html

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  mzimmers
                                  wrote on 11 Nov 2011, 00:53 last edited by
                                  #16

                                  Excellent...thanks again.

                                  1 Reply Last reply
                                  0
                                  • E Offline
                                    E Offline
                                    Eddy
                                    wrote on 11 Nov 2011, 06:48 last edited by
                                    #17

                                    [quote author="mzimmers" date="1320972557"]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

                                    [/quote]

                                    You could make a doc note / wiki page for that and it will be documented...

                                    Qt Certified Specialist
                                    www.edalsolutions.be

                                    1 Reply Last reply
                                    0
                                    • S Offline
                                      S Offline
                                      seaworthy
                                      wrote on 13 Jan 2013, 17:54 last edited by
                                      #18

                                      Run this script in the folder where your project is located. It will fix rename the files and change their contents accordingly.

                                      @#!/bin/bash
                                      echo "old: $1", "new: $2"

                                      rename "s/$1/$2/" *
                                      cd $2
                                      rename "s/$1/$2/" *
                                      find $NEW -type f -exec sed -i "s/$1/$2/g" {} ;

                                      echo "Done"@

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved