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. How to include a existing file into a different project?

How to include a existing file into a different project?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.1k 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.
  • collycrkC Offline
    collycrkC Offline
    collycrk
    wrote on last edited by
    #1

    Right clicking on the project and selecting a file from another project I know.
    What happens after the file is there that eludes me.
    How can the selected file be assimilated into this project?

    How to print a dialog in Qt seems to be beyond my comprehension. Would you like to teach me this one skill. If so, lets talk!

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      What happens after the file is there that eludes me.

      Nothing extraordinary happens. All files are added the same in the .pro file. The one will just have a path outside of your project directory, e.g.

      SOURCES += main.cpp \
                 some_file_in_your_project_dir.cpp \
                 ../../../some_other_project/file_from_that_other_project_dir.cpp
      

      To compiler it makes no difference where the file is.

      How can the selected file be assimilated into this project?

      What exactly do you mean by "assimilated "?

      collycrkC 1 Reply Last reply
      0
      • Chris KawaC Chris Kawa

        What happens after the file is there that eludes me.

        Nothing extraordinary happens. All files are added the same in the .pro file. The one will just have a path outside of your project directory, e.g.

        SOURCES += main.cpp \
                   some_file_in_your_project_dir.cpp \
                   ../../../some_other_project/file_from_that_other_project_dir.cpp
        

        To compiler it makes no difference where the file is.

        How can the selected file be assimilated into this project?

        What exactly do you mean by "assimilated "?

        collycrkC Offline
        collycrkC Offline
        collycrk
        wrote on last edited by
        #3

        @Chris-Kawa
        The file is included but it is fully qualified.
        Ex: C:/a/b/file

        Should I copy it into the receiving project and then add it?

        How to print a dialog in Qt seems to be beyond my comprehension. Would you like to teach me this one skill. If so, lets talk!

        1 Reply Last reply
        0
        • Chris KawaC Online
          Chris KawaC Online
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by Chris Kawa
          #4

          It depends what you want to do.

          • You can leave the absolute path. It's a bad idea in general and of course will not work on other computers.
          • You can change the path to be relative to the project directory e.g. if file is in directory C:/a/b/ and your project is in C:/a/c/ then you can use ../c/file. This is a good idea if you can ensure that this other project will always be located in the same relative directory to yours. This is usually the case when you're working with subprojects.
          • You can copy the file to your project dir and include it. This basically means your project now has no ties to the other project. You have two copies of the file and any changes to one will have no reflection in the other. This is basically a fork and you'll have to manually keep changes in sync if you need to.

          Your choice.

          collycrkC 1 Reply Last reply
          0
          • Chris KawaC Chris Kawa

            It depends what you want to do.

            • You can leave the absolute path. It's a bad idea in general and of course will not work on other computers.
            • You can change the path to be relative to the project directory e.g. if file is in directory C:/a/b/ and your project is in C:/a/c/ then you can use ../c/file. This is a good idea if you can ensure that this other project will always be located in the same relative directory to yours. This is usually the case when you're working with subprojects.
            • You can copy the file to your project dir and include it. This basically means your project now has no ties to the other project. You have two copies of the file and any changes to one will have no reflection in the other. This is basically a fork and you'll have to manually keep changes in sync if you need to.

            Your choice.

            collycrkC Offline
            collycrkC Offline
            collycrk
            wrote on last edited by
            #5

            @Chris-Kawa
            Thank you very much for your helpfulness Chris, your da-man!

            How to print a dialog in Qt seems to be beyond my comprehension. Would you like to teach me this one skill. If so, lets talk!

            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