Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt Creator - Relative paths



  • Allo,
    Qt Creator doesn’t seem to be using Relative paths.

    I am on Kubuntu 20.10.
    My account is in
    /home/john
    and my projects are in
    /home/john/qt-workspace/MyProject

    In my project, on the left side, I click on the Projects button. It has a wrench icon on it.
    The build directory is
    /home/john/qt-workspace/MyProject/build-MyProject-Desktop_Qt_5_9_9_GCC_64bit-Debug

    Then, I copied the MyProjects folder to my other profile = Jake
    /home/jake

    When I open Qt Creator, when I open my project
    The build directory is still
    /home/john/qt-workspace/MyProject/build-MyProject-Desktop_Qt_5_9_9_GCC_64bit-Debug
    ^^^^^Notice the john
    This is bad.

    Is this my fault? Did I do something wrong?
    Because if I give this project to others, nobody will be able to compile it since they don’t have a profile named john. Everyone has a different username.


  • Lifetime Qt Champion

    @stretchthebits If you copy a Qt project delete the *.pro.user file before opening it in QtCreator.
    You also should not add this file to your code version system.



  • @jsulm said in Qt Creator - Relative paths:

    If you copy a Qt project delete the *.pro.user file before opening it in QtCreator.
    You also should not add this file to your code version system.

    I tried that. Whenever I apply a solution it breaks something else it seems.
    Now, if I open MyProject.pro file with Qt Creator, I get a “Configure Project” page that opens in Qt Creator.
    It wants me to select

    1. Desktop Qt 5.12.2 GCC 64 bit
    2. Desktop Qt 5.14.2 GCC 64 bit
    3. Desktop Qt 5.9.9 GCC 64 bit
      and there are checkboxes that I can click next to those 3 options.
      and there is a Configure Project button at the bottom.

    I click on Configure Project and it recreates the user file.
    Can we keep the user file and have Qt Creator use relative paths?
    That seems to be the proper way to design an IDE.



  • @stretchthebits said in Qt Creator - Relative paths:

    Can we keep the user file and have Qt Creator use relative paths?
    That seems to be the proper way to design an IDE.

    This is a user forum; we're users just like you. Seems to me you're going to have to work as best you can with however it works. I don't know, but most configuration files are text files, maybe you could grep through to spot the old path references and update them if you want to preserve the file?



  • go to /home/jake/MyProject/build-MyProject-Desktop_Qt_5_9_9_GCC_64bit-Debug and do:
    make distclean to clean this dir up completely or
    simply remove this dir before you launch qt creator
    I think the old Makefile is still there.

    Or before you copy your project over, do make distclean first in or remove build-MyProject-Desktop_Qt_5_9_9_GCC_64bit-Debug
    of course in Release as well.

    I confirmed the Makefile has local info. Therefore, it has to be removed for a new user.



  • @JonB Thanks JonB and JoeCFD.
    Yes, I opened those files and did the change but perhaps it is better to get rid of absolute paths.
    I created a bug report
    https://bugreports.qt.io/browse/QTCREATORBUG-25863

    JonB:
    Yes, the old Makefile was still there since I just transferred all projects to my new user name = jake
    It was just a HDD to HDD copy, so it is fast.

    Yes, you are right. Makefile has absolute paths but that is not really important if I place my project on sourceforge.
    I don’t give them
    build-MyProject-Desktop_Qt_5_9_9_GCC_64bit-Debug
    build-MyProject-Desktop_Qt_5_9_9_GCC_64bit-Release

    but technically, Makefile should not contain absolute paths either.


  • Lifetime Qt Champion

    @stretchthebits said in Qt Creator - Relative paths:

    Can we keep the user file and have Qt Creator use relative paths?

    Things like build folder or the Kit used to build a project are not part of the project configuration for good reasons. Often different developers with different environments (or even different OS) work on same project. So, why should project configuration contain things that will be likely different for different developers? Maybe developer A uses different Kits than developer B and developer C prefers to have the build folder somewhere else and developer D works on Linux instead of Windows, so the paths are anyway invalid. The pro.user file is not even stored in the version control systems in real projects...
    I already worked on many projects with many other developers and things like these NEVER were stored as part of the project.



  • @jsulm I see.


Log in to reply