linuxqtfile-ownershipqfileinfo

Set file owner:group in Linux using Qt/C++


I need to change the owner and group of a file under Linux using Qt 5.7 /C++. I found the QFileInfo::ownerID and QFileInfo::groupID getters, but there appear to be no setters for these values.

I need the Qt equivalent of chown.

Is there a way to set these values using Qt functions?


Solution

  • Setting file permissions can be done by QFile::setPermissions method instead of using native chmod function, but Qt has not equivalent of chown. You should use chown() function from unistd.h Look here.