Results 1 to 19 of 19

Thread: getting filenames

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: getting filenames

    Maybe it will be easier if you use QFileDialog::getOpenFileNames()? The user will have a chance to choose images he wants.

  2. #2
    Join Date
    Nov 2007
    Posts
    47
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    34

    Default Re: getting filenames

    I guess I have one more question (never enough ).

    In the above code (2 postings back), if I wanted to replace the filenames in "list" with absolute paths + filename, how would I do that? Is there a convenient filter for that?

    In other words, instead of getting "filename1.jpg" I want to get "c:/myfolder/filename1.jpg".

    Thanks.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: getting filenames

    Qt Code:
    1. QDir dir( path );
    2. dir.setNameFilters( QStringList() << "*.png" << "*.jpg" << "*.bmp" << "*.gif" << "*.tiff" );
    3.  
    4. QFileInfoList fiList( dir.entryInfoList( QDir::Files, QDir::Name ) );
    5. foreach( const QFileInfo & fi, fiList ) {
    6. list << fi.absoluteFilePath();
    7. }
    To copy to clipboard, switch view to plain text mode 

  4. The following user says thank you to jacek for this useful post:

    ht1 (29th November 2007)

  5. #4
    Join Date
    Nov 2007
    Posts
    47
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    34

    Default Thank You!!!

    Amazing!

    Thanks a lot, Jacek

  6. #5
    Join Date
    Dec 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: getting filenames

    Hello i have a problem with that source.
    i was develop a simple program that use it my method is this
    Qt Code:
    1. void mainGUI::fuentes()
    2. {
    3. QStringList files;
    4. QDir directory= QDir(QDir::currentPath());
    5. files = directory.entryList(QStringList("*.ttf"),
    6. QDir::Files );
    7. comboBox->addItems(files); }
    To copy to clipboard, switch view to plain text mode 

    This method work online when i run the program in KDevelop or by Konsole but when i go to run by Konqueror or other windows manager it doesnt work the program doesnt show the filename in the combobox.
    Thanks

  7. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: getting filenames

    Quote Originally Posted by wyxknouth View Post
    This method work online when i run the program in KDevelop or by Konsole but when i go to run by Konqueror or other windows manager it doesnt work the program doesnt show the filename in the combobox.
    Take a look at http://wiki.qtcentre.org/index.php?t...king_directory.
    J-P Nurmi

  8. #7
    Join Date
    Dec 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: getting filenames

    Quote Originally Posted by jpn View Post
    Thanks a lot jpn, it work now.

Similar Threads

  1. Preserving filenames in QProcess
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 20th June 2007, 22:00

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.