Results 1 to 6 of 6

Thread: how do load image

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    61
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: how do load image

    Thanks for your reply...


    i am beginner .....I don't know in deapth


    So give the sample code to upload image from my system



    Thanks

    Yuvaraj R

  2. #2
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how do load image

    Qt Code:
    1. QPixmap Sender::selectImg(int i){
    2. QPixmap image;
    3. switch (i){
    4. case 0: image.load(":/quatroestacoes/primavera");
    5. break;
    6. case 1: image.load(":/quatroestacoes/verao");
    7. break;
    8. case 2: image.load(":/quatroestacoes/outono");
    9. break;
    10. case 3: image.load(":/quatroestacoes/inverno");
    11. break;
    12. case 4: image.load(":/quatroestacoes/as4estacoes");
    13. }
    14. return image;
    15. }
    To copy to clipboard, switch view to plain text mode 

    In this function i select an imagem, load it into a QPixmap object, and the return it to the call point.

    You must replace ...
    Qt Code:
    1. image.load(":/quatroestacoes/as4estacoes");
    To copy to clipboard, switch view to plain text mode 
    ... by something like ...
    Qt Code:
    1. image.load("yourpath/imagename.png");
    To copy to clipboard, switch view to plain text mode 
    ... if you have not created the resource file.
    ...but there are many other ways to do it

  3. #3
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how do load image

    Here is a simple one:
    Qt Code:
    1. ui->receiverLight->setPixmap(QPixmap("imagens/off.png"));
    To copy to clipboard, switch view to plain text mode 
    Where:
    • receiverLight is a QLabel object
    • the file name of the image is off.png

  4. #4
    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: how do load image

    Dont you have access to Qt Demos ? It is a very good place to start with.
    You will get almost every example you need for a beginner .

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. Load an image in QLabel
    By zeeb100 in forum Qt Programming
    Replies: 9
    Last Post: 13th March 2009, 13:51
  3. Is there a better way to load a big image?
    By learning_qt in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2008, 15:00
  4. best way to load image from db
    By C167 in forum Qt Programming
    Replies: 2
    Last Post: 10th April 2008, 18:24
  5. how to load a Qt non-supported Image format
    By Nithya in forum Qt Programming
    Replies: 5
    Last Post: 3rd April 2008, 12:57

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.