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. Creating new project from existing files
Forum Updated to NodeBB v4.3 + New Features

Creating new project from existing files

Scheduled Pinned Locked Moved Qt Creator and other tools
26 Posts 4 Posters 32.1k Views 1 Watching
  • 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 11 Mar 2011, 17:40 last edited by
    #1

    Hi, all -

    I want to try importing a small project (currently about 10 files) into the Qt environment, so I can use tools like the Qt debugger. I'm not actually ready to use Qt's GUI stuff; I just want to get further acquainted with the environment.

    With this in mind, which is the preferred way to get my files into a new project?

    Thanks.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on 11 Mar 2011, 18:06 last edited by
      #2

      You just use QtCreator to create a C++ project and add the files
      The compile and start debugging...

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mzimmers
        wrote on 11 Mar 2011, 18:24 last edited by
        #3

        Is it OK if I create the project using the directory with the existing files? Or, is that going to give me a conflict between my main.cpp and the one that Qt wants to make for me?

        Also, when I create a project, will it create and maintain a makefile for me?

        Thanks.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on 11 Mar 2011, 18:25 last edited by
          #4

          QMake has a special command line parameter you can use to create a .pro file. Maybe you can use that?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on 11 Mar 2011, 18:35 last edited by
            #5

            The command is:

            @
            qmake -project
            @

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on 11 Mar 2011, 18:40 last edited by
              #6

              [quote author="Gerolf" date="1299868515"]The command is:

              @
              qmake -project
              @
              [/quote]

              I thought I'd leave looking that up as an excercise for the reader ;-)

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on 11 Mar 2011, 18:48 last edited by
                #7

                sory, should I remove it, calling it censored?

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mzimmers
                  wrote on 11 Mar 2011, 21:00 last edited by
                  #8

                  Thanks, guys. I normally appreciate the value of exercises for the reader. If I don't get this code imported into Qt today, though, at least to where I can edit, build and do some rudimentary debugging, I may have to shelve Qt for the time and stay with the IDE that's currently giving me problems. So, for today anyway, product is more important than process.

                  So...is it OK if I build the project on top of a directory structure with subdirectories for source and includes? Or, is it better if I start with an empty project and import my files into it?

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on 11 Mar 2011, 21:27 last edited by
                    #9

                    It is perfectly ok to start on top of the existing dir. But I personally would create a backup copy - just to be on the safe side.

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

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mzimmers
                      wrote on 11 Mar 2011, 21:46 last edited by
                      #10

                      Thanks, Volker. I guess what I'm trying to get at here is, there doesn't seem to be a traditional "import" function. I can create new files, or I can add existing files (but they don't "move" into the Qt directory structure). I was hoping that if I created my Qt project on top of an existing directory structure (which currently only contains two subdirectories), Qt would magically "discover" the files, but that doesn't seem to work, either.

                      It's a small enough number of files that I can just create new ones and cut and paste the contents from the old directory structure, but I was hoping there was a "smarter" way to do this.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on 11 Mar 2011, 21:55 last edited by
                        #11

                        That works as you expect it. Just cd into the toplevel directory of your project (that containing the two subdirs) and call

                        @
                        qmake -project
                        @

                        on the command line. This leaves a xxx.pro file in the dir, named after your directory. You can rename it it you want. qmake scans the dir recursively and puts all the header, implementation an UI files into the project file.

                        Then just open this .pro file in Creator and adjust all the settings.

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

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

                          OK, so...I hate to look like a thorough moron here, but...no use leaving things half-done.

                          I'm really inexperienced at command line stuff. I tried adding the path to the qmake program to my $PATH variable by adding this to my .bash_profile file:
                          @PATH="/Volumes/320 GB HD/Developer/Tools/Qt":$PATH
                          export PATH
                          @
                          But it still says qmake's not found. I realize this isn't a Qt question, but can someone tell me what I'm doing wrong here?

                          Thanks...

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on 11 Mar 2011, 22:15 last edited by
                            #13

                            I don't know the directory layout the prebuilt Qt packages for the Mac (I suppose this from the "/Volumes/" path :-) ), but it might be that you have to append /bin after the Qt.

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

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              mzimmers
                              wrote on 11 Mar 2011, 22:25 last edited by
                              #14

                              No, the path name is good...in that directory is a file (actually a link) called qmake. I just realized, though, that the link points to a directory that isn't there (/usr/bin/qmake-4.7). Perhaps I'd better uninstall and reinstall Qt?

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                goetz
                                wrote on 11 Mar 2011, 22:27 last edited by
                                #15

                                You might use spotlight to search for the location of qmake. It is available on the commandline too:

                                @
                                mdfind -name qmake
                                @

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

                                1 Reply Last reply
                                0
                                • M Offline
                                  M Offline
                                  mzimmers
                                  wrote on 11 Mar 2011, 22:36 last edited by
                                  #16

                                  Thanks for the tip on mdfind.

                                  The qmake file really doesn't seem to be there. I think I'd like to start over with Qt; what's the clean way to uninstall it?

                                  1 Reply Last reply
                                  0
                                  • G Offline
                                    G Offline
                                    goetz
                                    wrote on 11 Mar 2011, 22:44 last edited by
                                    #17

                                    [quote author="mzimmers" date="1299882964"]Thanks for the tip on mdfind.

                                    The qmake file really doesn't seem to be there. I think I'd like to start over with Qt; what's the clean way to uninstall it?[/quote]

                                    Sorry, I really don't know. I started with Qt at the Mac long before the binary packages and had to compile it manually, so I stick to this until now :-)

                                    You might search the forum here, if I remember correctly, this was covered some time ago.

                                    What's really strange is, that there is no qmake - it looks as if the setup did not install every piece correctly. Did you install the SDK or only the Qt libs (aka framework)?

                                    And were you asked for an administrator password? Directory /usr/bin is root owned, even as user with admin privileges you must sudo to write to it.

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

                                    1 Reply Last reply
                                    0
                                    • M Offline
                                      M Offline
                                      mzimmers
                                      wrote on 11 Mar 2011, 22:55 last edited by
                                      #18

                                      I don't remember the details of when I installed it the first time. I know that I've been around this tree once before.

                                      I'm just going to wipe out the directories, reinstall and hope for the best. I'll report back in a bit.

                                      1 Reply Last reply
                                      0
                                      • G Offline
                                        G Offline
                                        goetz
                                        wrote on 11 Mar 2011, 22:56 last edited by
                                        #19

                                        Good luck!

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

                                        1 Reply Last reply
                                        0
                                        • M Offline
                                          M Offline
                                          mzimmers
                                          wrote on 11 Mar 2011, 23:31 last edited by
                                          #20

                                          Ahhhhhh...MUCH better!

                                          I now have a qmake program (and who knows what else), and the new project created successfully over the existing source directories.

                                          Qt also logically collects the files in the directory into Headers and Sources, so my existing directories created a second, undesired level of indirection. I moved all the files into one directory and did it over, and it seems fine now. (I might say that it's just a tad undesirable for Qt to do that, as it would be nice if I could preserve an existing directory structure, but...I'm not in the mood for complaining.)

                                          Thanks for all the help, guys. It does seem better to do it from the command line.

                                          BTW: the -project switch for qmake is undocumented, at least when you type "qmake" in the terminal window.

                                          1 Reply Last reply
                                          0

                                          1/26

                                          11 Mar 2011, 17:40

                                          • Login

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