Results 1 to 9 of 9

Thread: Image loading

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Image loading

    Hi!

    I am trying to get the path top a QImage for my application.
    I did as followd:

    Qt Code:
    1. QPixmap image;
    2.  
    3. image.load(QCoreApplication::applicationDirPath() + "/Desktop/myImage");
    To copy to clipboard, switch view to plain text mode 

    My problem is that I can not load any image.

    What could be the problem? I will appreciate any help.

    Many thanks in advance.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCoreApplication

    Where is the image name ? "myImage.png" , myImage.jpg ?? which one ?

    Also what is the output of QCoreApplication::applicationDirPath() ?

  3. #3
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCoreApplication

    Many thanks aamer4yu for your reply.
    The image name should be myImage.png.
    Have a look please. When I proceed as followed, I do not need to add ".png", and I can have the image loaded. But I do not want to go this way.

    Qt Code:
    1. image.load("C:/Users/Desktop/myImage");
    To copy to clipboard, switch view to plain text mode 

    Even by writing myImage.png, there is no change.

    I have created a label on which th image should appear as followed:
    Qt Code:
    1. m_image = new QLabel(this);
    2. m_image->setPixmap(myImage);
    To copy to clipboard, switch view to plain text mode 
    Last edited by Stanfillirenfro; 15th January 2014 at 10:43.

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCoreApplication

    Are you sure you know what QCoreApplication::applicationDirPath() returns ?

  5. #5
    Join Date
    Jan 2012
    Posts
    83
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QCoreApplication

    Thanks Lesiok!

    Yes, QCoreApplication::applicationDirPath() returns the directory that contains the application executable.

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QCoreApplication

    Please put a qDebug() for QCoreApplication::applicationDirPath() value...

Similar Threads

  1. Loading Image
    By navi1084 in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2011, 05:07
  2. Loading an image into memory
    By Luc4 in forum Qt Programming
    Replies: 6
    Last Post: 12th April 2010, 08:44
  3. loading image from disk
    By freekill in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2010, 05:21
  4. problems loading an image .jpg
    By maider in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2009, 11:57
  5. Image Loading
    By kavinsiva in forum Qt Programming
    Replies: 2
    Last Post: 11th August 2009, 08: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.