Results 1 to 6 of 6

Thread: get .pro directory

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default get .pro directory

    I would like to get the path of the main .pro file. The problem is that I use shadow build so isn't the same dir and can't use QDir::currDir().
    Maybe $$_PRO_FILE_PWD_ should do the trick, but how ?
    I tried putting this in .pro

    debug {
    DEFINES += DEBUGGING
    DEFINES += "PWD_PRO=$$_PRO_FILE_PWD_"
    }

    how to read PWD_PRO ? if I do
    qDebug() << PWD_PRO;

    PWD_PRO is expanded right to directory tree, but the compiler gives errors
    There is some method to do this ?

    thanks in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: get .pro directory

    but the compiler gives errors
    it will help if you can post the errors.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: get .pro directory

    thanks for quick replay

    this is the code in cpp
    Qt Code:
    1. #ifdef Q_WS_X11
    2. #ifdef DEBUGGING
    3. qDebug() << PWD_PRO;
    4. #else
    5. ...
    6. #endif
    7. #endif
    To copy to clipboard, switch view to plain text mode 

    compiling this gives:
    ../MediaDownloader/main/styles.cpp:41:17: error: expected primary-expression before ‘/’ token
    ../MediaDownloader/main/styles.cpp:41:17: error: ‘home’ was not declared in this scope
    ../MediaDownloader/main/styles.cpp:41:17: error: ‘deimos’ was not declared in this scope
    ../MediaDownloader/main/styles.cpp:41:17: error: ‘Lavori’ was not declared in this scope
    ../MediaDownloader/main/styles.cpp:41:17: error: ‘workspace’ was not declared in this scope
    ../MediaDownloader/main/styles.cpp:41:17: error: ‘MediaDownloader’ was not declared in this scope

    that are actualy the path

    thanks again

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: get .pro directory

    Can you show few (code) lines before and after the line of the first error?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: get .pro directory

    sure:
    Qt Code:
    1. QFileInfoList styles::getCssFileList()
    2. {
    3. #ifdef Q_WS_X11
    4. #ifdef DEBUGGING
    5. qDebug() << PWD_PRO;
    6. // CSSpath.setPath(QDir::currentPath()+"/css/");
    7. #else
    8. CSSpath.set Path(QDir::homePath()+"/.mediadownloader/");
    9. #endif
    10. #endif
    11.  
    12.  
    13. #ifdef Q_WS_WIN
    14. CSSpath.setPath(QDir::currentPath()+"/css/");
    15. #endif
    16.  
    17. if (!CSSpath.exists()) CSSpath.mkdir(CSSpath.absolutePath());
    18.  
    19. CSSpath=CSSpath.toNativeSeparators(CSSpath.absolutePath());
    20. return CSSpath.entryInfoList(QStringList("*.css"),QDir::Files,QDir::Name);
    21. }
    To copy to clipboard, switch view to plain text mode 

    the function is declared static, but even if I put the qDebug() into constructor it gives error

  6. #6
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: get .pro directory

    actually I managed this with "#" directive, but my brain can't reach this

    Qt Code:
    1. #define QUOTEME_(x) #x
    2. #define QUOTEME(x) QUOTEME_(x)
    To copy to clipboard, switch view to plain text mode 

    then doing
    Qt Code:
    1. qDebug() << QUOTEME(PWD_PRO);
    To copy to clipboard, switch view to plain text mode 
    will exand as I want

    sorry was a c++ related topic not Qt

Similar Threads

  1. Server directory
    By fitzy in forum Qt Programming
    Replies: 4
    Last Post: 7th October 2009, 11:51
  2. Set Working Directory in VS
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2008, 17:03
  3. Specify the DLL directory
    By Nyphel in forum Newbie
    Replies: 6
    Last Post: 27th April 2007, 14:29
  4. Size of the directory
    By npc in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2006, 07:05
  5. Active Directory and Qt
    By chak_med in forum Qt Programming
    Replies: 1
    Last Post: 6th December 2006, 19:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.