Results 1 to 4 of 4

Thread: QDir::setCurrent with resource files

  1. #1

    Default QDir::setCurrent with resource files

    Is there a way to change the current directory to something in the resource directory? for example:

    Qt Code:
    1. QDir dir(":/resources/html");
    2.  
    3. dir.setFilter(QDir::Files | QDir::NoSymLinks);
    4. dir.setSorting(QDir::Name);
    5. QFileInfoList list = dir.entryInfoList();
    6.  
    7. Q_ASSERT(QDir::setCurrent(":/resources/html"));
    To copy to clipboard, switch view to plain text mode 

    I nthe above example, list has exactly the files in It I think it should, but the program keeps quitting because the setCurrent call is returning false.

    Can I simply not do what I am trying to do here?

  2. #2
    Join Date
    Apr 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDir::setCurrent with resource files

    I think you should call like this instead

    Qt Code:
    1. QDir::setCurrent(dir.absolutePath());
    To copy to clipboard, switch view to plain text mode 

  3. #3

    Default Re: QDir::setCurrent with resource files

    That does not work either. Thanks though.....

  4. #4
    Join Date
    Apr 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDir::setCurrent with resource files

    Yea most likely because absolutePath in your case is not giving a fully qualified path which I assume is what setCurrent is wanting. I use the Qt Resource System too and I compile it into the executable. For instance ":/<myprefix>" is resource data compiled into the application for immediate access. I'm not confident that you can do what you are trying as ":/<prefix>" are resource paths and not your typical file system paths. Hopefully I said something useful. Cheers and good luck.

Similar Threads

  1. Loading images from resource files in webkit
    By redserpent7 in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2015, 14:01
  2. How to compile qt resource files?
    By yangyunzhao in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2009, 07:46
  3. QDir::NoDotAndDotDot hidding all files?
    By been_1990 in forum Qt Programming
    Replies: 2
    Last Post: 3rd July 2009, 04:12
  4. Replies: 2
    Last Post: 5th September 2007, 23:31
  5. Qt4: QDir::entryList bug in windows when listing network files?
    By Yvon Halbwachs in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 15:22

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.