Results 1 to 3 of 3

Thread: display filename

  1. #1
    Join Date
    Mar 2010
    Posts
    54
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default display filename

    Hi
    I have a small code where I am able to display the images

    Qt Code:
    1. void FrameDisplay::populate()
    2. {
    3. QDir dir("/home/kamlesh/Gall/GALL/images/eBeam Gallery/Art & Design/2D Shapes");
    4. dir.setFilter(QDir::Files);
    5. QImage thumb, tmp;
    6. int sizeW = 32;
    7. int sizeH = 32;
    8. QStringList listfiles = dir.entryList(QStringList()<<"*.png",QDir::Files);
    9. for(int i=0;i<listfiles.count();i++)
    10. {
    11. modl->setRowCount(listfiles.count());
    12. modl->setColumnCount(2);
    13. QString filename = listfiles.at(i);
    14. QString filepath = dir.absoluteFilePath(filename);
    15. bool x = tmp.load(filepath);
    16. //bool x = tmp.load("/home/kamlesh/Gall/GALL/images/eBeam Gallery/Art & Design/2D Shapes/Black Hexagon.png");
    17. if(x == true)
    18. {
    19. thumb = (tmp.scaled( 240, 480 ).scaled( sizeW, sizeH, Qt::IgnoreAspectRatio )); //two passes
    20. modl->setData( modl->index( i, 0 ), thumb, Qt::DecorationRole );
    21. }
    22.  
    23. }
    24. //listwidget->addItems(listfiles);
    25. viw->setModel(modl);
    26. viw->show();
    27.  
    28. }
    To copy to clipboard, switch view to plain text mode 

    But I also need to display the filenames with the images
    How should I setdata for the model to display the filenames also ?

    Please help

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: display filename

    Have you tried to use an additional role? Eg. DisplayRole

  3. #3
    Join Date
    Mar 2010
    Posts
    54
    Qt products
    Qt/Embedded
    Platforms
    Symbian S60

    Default [solved] display filename

    HI
    Solved the issue

    by adding the line

    modl->setData( modl->index( i, 1 ), filename, Qt:ecorationRole );

Similar Threads

  1. Getting filename by QFileDialog
    By Rajeshsan in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2010, 09:36
  2. Filename -> directory
    By Persoontje in forum Newbie
    Replies: 2
    Last Post: 2nd December 2009, 22:54
  3. how to get filename
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2009, 08:59
  4. get filename from a QFileDialog
    By graciano in forum Qt Programming
    Replies: 2
    Last Post: 17th November 2009, 14:57
  5. How can I get a filename from a different encoding?
    By Pepe in forum Qt Programming
    Replies: 4
    Last Post: 28th March 2007, 00:18

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.