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

Include from path partially solved



  • I have imported an inlude file (device..h) from a path . how do I #include it ?c07c5637-9b9c-44cd-b16c-5aaea6bd019b-image.png

    Addendum
    After adding most of the "foreign" project files , including .cpp, I no longer have undefined includes, but now I cannot write into "device.h" when "build" wants to save it.

    I do get a dialogue asking to change write permission but it does not really change it .

    Error dialogue
    "Cannot set permissions for /media/z/DEV_COPY_LABEL/Qt/Qt_TEST/GIT_Bluetooth_TEST/examples/bluetooth/btscanner/device.h to writable.
    Could not save the files."

    I also have double main.cpp - I’ll delete the second one, easy.

    e12127c5-48f6-48b4-9757-de0c886506c0-image.png


  • Qt Champions 2019

    @AnneRanch said in Include from path partially solved:

    Cannot set permissions for /media/z

    Check how that device was mounted (read-only?) and how the access rights for directories and files are set there, is not a Qt issue. Also, it would be a good idea to simply copy the needed stuff from that external device to your local file system.



  • " needed stuff from that external device to your local file system."
    You are joking, right ?

    **Or adding path to Qt project does not work ?? **

    1. The "device.h" has no write permission issues when used "locally" , only when referenced using full path in project .
      See the original tree view.
    2. AS i said - I will receive a dialogue telling me if I what TO CHANGE the permissions. When I do so I get an error - hence it is Qt NOT performing the change .

    If Qt is unable to do so - why advertise it will?

    I have solved the issue by rebuilding the "includes " locally.

    I should be able to "include" from other projects and like to get an answer for that.



  • @AnneRanch said in Include from path partially solved:

    If Qt is unable to do so - why advertise it will?

    Please remember: @jsulm, and the rest of us, are just users of Qt, like you are. We do not work for The Qt Company, we do not advertise it, we do not benefit, we just try to answer other peoples' questions to help out.

    I do not understand why anything is trying to trying to set the file to writable or write back to it. When you #include a file, from whatever path, it is just read during the compilation process. Nothing in Qt or otherwise should be trying to write back to it. Now, if you have chosen to read that file into Qt Creator and then modified it, either accidentally or on purpose, that would require write back. But that should not be the case. You should not be making changes to any of the files which your screenshot shows are on the /media/z/... device. If you do need to change such files, you would have to copy them off the read-only device and use that in your project instead.



  • @AnneRanch said in Include from path partially solved:

    I should be able to "include" from other projects and like to get an answer for that.

    Like @JonB already said, just including should not be a problem. If you edit this file in Qt Creator and try to run the project, QtC tries to save the changes first before building and running your project... and this process can not work if either you (i.e. your user) or the user that runs QtC don't have the permission to write to that file or even change (through QtC - the dialog) the unix permission (rwx) on these dirs / files.

    This is not a Qt issue....
    If you have cloned the git stuff into one directory, you could try to give your user the permission to write to these files and everything in it's subdirectories.

    What I can tell from just looking at your screenshot:
    It seems that you have cloned your git rep into an existing project folder of yours (or added the cloned files to that project, at least). That's why you have two main.cpp files. One belongs to tabDialog and the other one to your BT Example...
    and that's not how examples supposed to work. Examples are standalone projects, that illustrate how things work or how some tasks could be realized

    @AnneRanch said in Include from path partially solved:

    If Qt is unable to do so - why advertise it will?

    QtC would be able to do so IF the user under which uid QtC is running, has the privileges to modify user rights or file / dir permissions... (a sudo user / admin / root user could, but running programs under root user privileges is not recommended, if it's not necessarily needed)


  • Qt Champions 2019

    @AnneRanch "You are joking, right ?" - wrong. It was a suggestion, if it is not feasible for you then just don't do it.
    So, you did not check how the device was mounted as I suggested? If the device was mounted in read-only mode nobody, including QtCreator, will be able to make the file writeable. It's up to you to not to follow suggestions, but why ask here then?

    "If Qt is unable to do so - why advertise it will?" - it's QtCreator, not Qt.


Log in to reply