Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8223625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:46:20+00:00 2026-06-07T14:46:20+00:00

I have the following *.pro files : the one which heads the solution #

  • 0

I have the following *.pro files :

the one which heads the solution

# head - pro file :
TEMPLATE = subdirs
CONFIG = qt thread ordered

# save root directory
PROJECT_ROOT_DIRECTORY = $$_PRO_FILE_PWD_
message("Master pro file path : ["$${PROJECT_ROOT_DIRECTORY}"]") // output : "Master pro file path : [/Path/To/Directory]"

# project subdirs
SUBDIRS += PROJECT1

and

# PROJECT1 - pro file :
TEMPLATE = app

# etc.

# output 'PROJECT_ROOT_DIRECTORY ' contents
message("Master pro file path : "$${PROJECT_ROOT_DIRECTORY}) // output :  "Master pro file path : []"

How do I pass variables between the 2 pro files (here the variable is PROJECT_ROOT_DIRECTORY) ?

Edit :

This is the same question as this this one, but I don’t see how the “another option is to” answer can help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:46:26+00:00Added an answer on June 7, 2026 at 2:46 pm

    You could put the variable definitions in a .pri file, which you then include in all .pro files you want. Note that you need to tell the .pro files in your subdirectories the path where to find the .pri file.

    head.pro:

    # head - pro file :
    TEMPLATE = subdirs
    CONFIG = qt thread ordered
    
    # configuration
    include(config.pri)
    message("Master pro file path : ["$${PROJECT_ROOT_DIRECTORY}"]") # output : "Master pro file path : [/Path/To/Directory]"
    
    # project subdirs
    SUBDIRS += PROJECT1
    

    config.pri:

    # save root directory
    PROJECT_ROOT_DIRECTORY = $$PWD // not $$_PRO_FILE_PWD_!
    

    project1/project1.pro:

    # PROJECT1 - pro file :
    TEMPLATE = app
    
    # configuration
    include(../config.pri)  # note that you need to put "../" before the .pri path
    message("Master pro file path : ["$${PROJECT_ROOT_DIRECTORY}"]") # should now output :  "Master pro file path : [/Path/To/Directory]"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have built a simple GUI application in QtCreator-2.0.1 i have following files: first.pro
I have following script that executes all the .reg files in the current directory.
I have the following XML file: <?xml version=1.0?><!--This document contains the profiles that have
I am new to MVC and I have been following Steven Andersons Pro ASP.Net
I have a .NET 4.0 32 bit (x86) desktop application with the following files,
I have the following query in SQL which I would like to convert to
I have a C# solution composed of three projects in Visual Sudio 2010. One
I have a Qt subdirs project with the following structure: ExternalQtProject QtSubdirProjects - GUI
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have following source. In insertMessage(..), it calls selectMessage to check whether duplicate record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.