Results 1 to 4 of 4

Thread: [solved]QImage Load issue

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

    Default [solved]QImage Load issue

    Hi
    I have a small piece of code to load a list of images

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

    Issue is that , I am able to get the filename , but when I use
    QImage::load(filename)
    it returns FALSE value
    Last edited by kamlmish; 21st December 2010 at 10:16.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QImage Load issue

    have you debuged the content of filename? I guess it is only relative to dir. So you probably have to prepend that first.

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

    Default Re: QImage Load issue

    Even after appending the full path, QImage::Load doesnt work

    Qt Code:
    1. void MainWindow::listdisplay()
    2. {
    3. QDir dir("/home/kamlesh/Gall/GALL/images/eBeam Gallery/Art & Design/2D Shapes");
    4. dir.setFilter(QDir::Files);
    5. QList<QImage> images;
    6. QImage thumb, tmp;
    7. int sizeW = 20;
    8. int sizeH = 20;
    9. QStringList listfiles = dir.entryList(QStringList()<<"*.png",QDir::Files);
    10. for(int i=0;i<=listfiles.count();i++)
    11. {
    12. QString filename = listfiles.at(i);
    13. QString filepath = dir.absoluteFilePath(filename);
    14. bool x = tmp.load(filepath);
    15. //bool x = tmp.load("/home/kamlesh/Gall/GALL/images/eBeam Gallery/Art & Design/2D Shapes/Black Hexagon.png");
    16. if(x == true)
    17. {
    18. thumb = (tmp.scaled( 1240, 1480 ).scaled( sizeW, sizeH, Qt::KeepAspectRatio )); //two passes
    19. modl->setData( modl->index( i, 0 ), thumb, Qt::DecorationRole );
    20. }
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

    The images have been taken from MACOS, and the work environment is linux,qt
    Is that the issue ?

  4. #4
    Join Date
    Jun 2010
    Location
    Hangzhou, China
    Posts
    10
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QImage Load issue

    try use an easy directory instead of "/home/kamlesh/Gall/GALL/images/eBeam Gallery/Art & Design/2D Shapes/", such as "/tmp/1.png"
    hope to help you.

Similar Threads

  1. [Qt4] How to load Url image into QImage?
    By Gonzalez in forum Qt Programming
    Replies: 6
    Last Post: 13th October 2014, 10:10
  2. Unable to load gif file in QImage.
    By spsingh in forum Qt Programming
    Replies: 1
    Last Post: 2nd August 2010, 09:08
  3. [mac] QImage.load fails
    By snoopy67 in forum Qt Programming
    Replies: 4
    Last Post: 7th November 2007, 14:06
  4. Low-level error conditions on QImage.load()
    By bruccutler in forum Newbie
    Replies: 3
    Last Post: 19th January 2007, 21:09

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.