Results 1 to 5 of 5

Thread: How to set permissions to a file using QFile::setPermissions()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    8
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Lightbulb Re: How to set permissions to a file using QFile::setPermissions()

    thank you for your supply, but your suggest doesnt work to. I have changed my code like this:
    Qt Code:
    1. QString savefile = QFileDialog::getSaveFileName(this,"Save File", QDir::currentPath(),fillter0) + ".desktop";
    2. QFile myfile(savefile);
    3.  
    4. if(!myfile.setPermissions(QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|QFile::ReadGroup|QFile::ExeGroup|QFile::ReadOther|QFile::ExeOther))
    5. {
    6. qDebug("Something wrong!");
    7. }
    8.  
    9.  
    10. if(!myfile.open(QIODevice::WriteOnly | QIODevice::Text))
    11. return;
    12. QTextStream out(&myfile);
    13. out << preview;
    14. myfile.close();
    To copy to clipboard, switch view to plain text mode 
    But it doesnt work. So i guess it is not beacause the ORed statement. Could you please show me how?
    I read the Qt help, but couldnt find any thing could help.
    Thank you very much.

  2. #2
    Join Date
    May 2010
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to set permissions to a file using QFile::setPermissions()

    Where exactly is it failing? is it prematurely returning or are you getting your qdebug() message saying something is wrong?

  3. The following user says thank you to thenybbler for this useful post:

    g16bit (18th March 2011)

  4. #3
    Join Date
    Mar 2011
    Posts
    8
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to set permissions to a file using QFile::setPermissions()

    Ok. this problem was solved. thank you very much. A friend of mine tell me the wrong in my code. just put the if statement below the open file command. Thanks.

Similar Threads

  1. Replies: 3
    Last Post: 28th March 2009, 15:37
  2. QFile can't read a file
    By Raccoon29 in forum Qt Programming
    Replies: 3
    Last Post: 11th February 2009, 20:24
  3. Replies: 1
    Last Post: 27th September 2008, 20:12
  4. Replies: 3
    Last Post: 11th September 2008, 20:08
  5. Replies: 1
    Last Post: 20th June 2008, 18:43

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
  •  
Qt is a trademark of The Qt Company.