Qt World Summit: Register Today!

How to add existing files to a project?

  • hi,

    I am new to qt creator.
    I am using ubuntu SDK. I have created a project and want to add some existing files to it.
    When I right click on the project, "add existing files" is not clickabe (disabled) for some reason I don't know.
    When I try to add using :
    File -> New File .... It gives File generation failure.

    So, is there any other way of doing it.

  • Moderators

    Maby Canonical broke something.

    Is your project qmake-based? It should work. If you are using QBS, then that feature is not available (yet).

  • thanks for the reply....
    qmake-based?...I don't know...but in order to get the .pro file I ran qmake -project.

  • Moderators

    OK so it is a qmake project. Looks like a bug from Canonical, then. This should work and is working for me with every platform and Qt Creator version I've tried (which is a lot).

  • One way to work around this would be to shut down Qt Creator and edit the project .pro file using a text editor; adding the files manually, before you open Creator again.

    The .h files need to be added to the HEADERS section and the .cpp in the SOURCES. You need to make sure the last file in the list before each of your additional ones has a space and then a \ after it.

    If you restart Qt Creator the files should be part of the project.

  • Moderators

    No need to restar, Qt Creator will reparse .pro file after it is modified.

Log in to reply