How can you create a hidden folder using Qt?



  • Hi all;
    in the applictaion i'm working on i would like to have a folder that would contain certain files. i also want to have a subfolder in the main folder that would contain metadata files. I would like to make the subfolder a hidden folder so it will not be viewable by the user. I looked into QDir and i can't see any way to make a folder hidden. i have checked the web and i can't seem to find anything. is Qt capable of this?

    Thanks for any help. :-)
    Shawn



  • well thats very specific for each platform. On a unix simply prepend a "." to the folder name then it is hidden.

    on Windows you have to use the Windows API. Qt doesnt handle hiding of files ad folders unfortunately.



  • Shawn,
    For which particular Platform are you doing this, As Flix said it is different on different platform, we can write code for atleaset two platform which may help you.

    Regards,
    Irfan Omair



  • Although it's so different depending on the platform, I think it would be possible to be part of Qt (there are APIs for other dir operations that are so different across the platforms too). :-)



  • Well you can implement your own platform independent api for this for all those platform you want it to support, as above said it so largely varies on different platform that I can understand why there is not any api for this in Qt, but you can have your own #ifdef and implement your own code, but you need to know the native api for all those platform you want it to work.



  • A similar thread on the subject exists here:
    http://developer.qt.nokia.com/forums/viewthread/2709/



  • There cannot be a platform independent way of creating hidden files or directories. The concepts are far too way different. While on Windows this is "only" an attribute to the file itself. On Unix/Linux there are no really "hidden" files. It's only by convention that files staring with a dot are not displayed by default. Thus, the lib would have to change the filename and prepend a dot to it. You would be unable to open your file afterwards with the original name since it simply doesn't exist and never has. Or, worse, there already exists a file with the dot in front of it and everything's messed up. On Mac things might go even worse, as it could be with both attributes and dot convention.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.