Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Simple C++ project build
QtWS25 Last Chance

[SOLVED] Simple C++ project build

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 8.2k 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.
  • S Offline
    S Offline
    Sidhartha
    wrote on last edited by
    #1

    Hi All,

    Sorry for the very basic question... I'm new to QtCreator.

    I have an exisiting C++ project. Simply a collection of .cpp and .h files, also I have a classic make file for compilation at the Linux command line using g++...

    My question... how do I import these files into QtCreator to create a new project...? This is just a pure vanilla C++ project that runs in the console.

    Many Thanks

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      it's easiest to use the wizard to start a new project and add your stuff afterwards.
      In the past there was a tutorial in the Qt Creator manual, but I don't see it any more.

      Follow these steps :
      create a new project > choose a project : other projects, console application.
      choose a name for the program and run it to test it out.

      have fun!

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sidhartha
        wrote on last edited by
        #3

        Hi Eddy,

        Thanks for your response. Sorry about this, but I'm still getting a little confused.

        Basically I want to use QtCreator as a basic C++ IDE (like CodeBlocks for example)... at this stage nothing related to Qt.

        All the projects I can create seem like Qt projects. The only way I seem to be able to start a project that isn't a Qt project is to 'import existing project'. When I do that, I don't seem to see a project tree in the projects pane, and by the looks of it I have to create my own make file.

        I know people have been using QtCreator as a straight C++ IDE... I just can't see how!

        If you could clear up any misconceptions I may have, or give me anymore pointers I'd appreciate it.

        1 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          It's a long time ago I used a console to generate a pro file, so I tried it out again first ;-)

          go to your directory where you have your main.cpp, headers and other cpp files.
          in a console type :
          @qmake -project@

          this wil create a pro file in which links to the headers and source files are made automatically.

          use Qt Creator to open the pro file you just generated and you'll see your files in there.

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sidhartha
            wrote on last edited by
            #5

            Thanks Eddy. Doesn't seem quite as straightforward as CodeBlocks if I'm honest, but the QtCreator front end is very nice.

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #6

              Glad you're up and running.

              Please edit your first post and add [solved] to it.

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #7

                One other note...

                When you're not going to be using Qt proper in your creator project, be sure and add the line
                @
                CONFIG -= QT
                @
                to prevent the project from trying to link in the Qt libraries.

                bq. Doesn’t seem quite as straightforward as CodeBlocks if I’m honest

                This is understandable, as Qt Creator is more specialized toward a certain project perspective (Qt project work) rather than being a general purpose C++ IDE (Though it makes a fine one.) These little caveats are just the price that you pay to step outside the main focus a little bit. I wouldn't worry about it too much, as the benefits of using Creator can easily overshadow the little idiosyncrasies involved with special use cases. :)

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sidhartha
                  wrote on last edited by
                  #8

                  Hi mlong,

                  thanks for your post. Just so I can this clear... after i've gone to the directory in terminal where my c++ headers and project files are and typed qmake -project I get a ,pro file that I can right click on and open in QtCreator...

                  after that QtCreator opens and asks me if I want to set up a desktop target. What's that? Just another directory for the debug or release I'm assuming?

                  Next question... you talk about adding the line CONFIG -= QT but I'm not quite sure where you mean I should be adding that line to?

                  Thanks for your time

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mlong
                    wrote on last edited by
                    #9

                    Yes, "qmake -project" will give you a base .pro file. By default it will be named the same as the directory you're currently in. So if you're in a directory called "foo", the project will be "foo.pro". You can rename it of course, if you'd like.

                    A desktop target just means you're telling Creator that you want to use a build of Qt that's targeted for desktop deployment (as opposed to Symbian or Harmattan for mobile devices.)

                    You'll want to add the CONFIG -= QT line to your .pro file. It can just be a line by itself in the file somewhere.

                    There's a lot of good information in the "qmake manual.":http://qt-project.org/doc/qt-4.8/qmake-manual.html#qmake

                    Software Engineer
                    My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                    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