Important: Please read the Qt Code of Conduct -

Tracking project versions using QDebug

  • I am using QDebug to track code execution.
    After recent mishap where edited files were not used by build I added
    qDebug FILE

    First line of "application output" ( in blue ) automatically identifies the project executable folder.

    I am curious where is it configured / activated.

    My question is
    can I identify the actual main project source folder in "application output" ?

    Using FILE works fine , but does to give full path. .

    Starting /home/f/build-TEST_PROJECT-Desktop-Debug/TEST_PROJECT...
    OK  Bluetooth local device detected  
    file      ../QT_PROJECT/TEST_PROJECT _1/mainwindow.cpp
    function  MainWindow
    @line     87

  • @AnneRanch
    A number of macros, including __FILE__, are defined for convenience by the C++ compiler, rather than being a Qt feature. See e.g.

    There are a number of posts out there to play with it if you want to pick out a segment from __FILE__.

    I don't know though whether Qt provides any macro for "the actual main project source folder in "application output" ". I kind of think not, but stand to be corrected.

    You could probably pass a -DSOMETHING=/path from the makefile --- which might know where the source folder is --- as an argument in your compilation line so that you can use the symbol in your source code. But that's more work.

Log in to reply