Results 1 to 8 of 8

Thread: Change File Attributes

  1. #1
    Join Date
    Jul 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Post Change File Attributes

    How to change the file attributes using Qt ?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Change File Attributes

    What attributes? QFile::setPermissions() can manipulate some permissions depending on OS.

  3. #3
    Join Date
    Jul 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Change File Attributes

    Quote Originally Posted by ChrisW67 View Post
    What attributes? QFile::setPermissions() can manipulate some permissions depending on OS.
    System , ReadOnly , Hidden , ...

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Change File Attributes

    Read-only is probably handled by QFile. The others you are talking about are non-portable Windows-only things and you need to use the Windows API.
    https://msdn.microsoft.com/en-us/lib...8VS.85%29.aspx

  5. #5
    Join Date
    Jul 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Change File Attributes

    Quote Originally Posted by ChrisW67 View Post
    Read-only is probably handled by QFile. The others you are talking about are non-portable Windows-only things and you need to use the Windows API.
    https://msdn.microsoft.com/en-us/lib...8VS.85%29.aspx
    I have problems understanding DWORD & LPCTSTR ...
    What are those classes (or structs) getting for their value??

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Change File Attributes

    They get whatever value you give them

    DWORD = 32-bit integer. The parameter value is made as a bitwise OR of the desired attribute values from API docs.
    LPCTSTR = Long Pointer to a Const TCHAR STRing. The value is the file name as, in this case, a const wchar_t*. You can get one of these from a QString using the utf16() or toWCharArray() functions.

  7. #7
    Join Date
    Jul 2015
    Posts
    16
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Change File Attributes

    Quote Originally Posted by ChrisW67 View Post
    They get whatever value you give them

    DWORD = 32-bit integer. The parameter value is made as a bitwise OR of the desired attribute values from API docs.
    LPCTSTR = Long Pointer to a Const TCHAR STRing. The value is the file name as, in this case, a const wchar_t*. You can get one of these from a QString using the utf16() or toWCharArray() functions.
    A question then , why API programmers didn't make a typedef int DWORD & typedef const wchar* LPCTSTR ??
    Aren't they equal ??
    What is HWND then ??

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Change File Attributes

    You would have to ask the original Windows programmers. I suspect it is combination of personal preference/common practice and because typedef did not become standard until until the 1989 ANSI standard (and not reliably available until after that). The first Windows versions would have been constrained to K&R C.

    HWND is a handle to a window (it is just a number with no encoded meaning). Look in your Windows header files to find what the macro expands to. A Qt widget can provide an equivalent HWND where one exists: see QWidget::winId()

Similar Threads

  1. Replies: 0
    Last Post: 5th July 2013, 15:58
  2. Replies: 7
    Last Post: 14th June 2010, 02:42
  3. How to change the attributes of a file
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 24th March 2010, 17:26
  4. Updating File attributes and it's summary details
    By senthilsp in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2009, 13:31
  5. Replies: 1
    Last Post: 23rd May 2008, 08:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.