Results 1 to 2 of 2

Thread: Show portion of an image

  1. #1
    Join Date
    Jan 2006
    Posts
    44
    Thanks
    9
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Show portion of an image

    I'm given an image that represents stages/levels along these lines. Each stage is represented as an complete "image" at the percentage and then copied vertically within the actual image file. Perhaps some ascii art will help with that poor description.

    Qt Code:
    1. ##########
    2. #########_
    3. ########__
    4. #######___
    5. ######____
    6. #####_____
    7. ####______
    8. ###________
    9. ##_________
    10. #__________
    To copy to clipboard, switch view to plain text mode 

    Each line in there represents a "sub image" - think similar to a fuel gauge.

    What I need to do is to display one sub image, one "line", based on some other data.

    I *could* do it by breaking the image up into separate images for each level[1], but I'd rather do it by showing a piece, given that the image may change and I'd rather avoid the manual step and recompile and just get the base image via http. I've got the retrieve and show part down, just need to know how to show the "sub image".

    I suspect I need a QGraphicsScene but I've not teased it out of the docs yet.

    1. If needs be i'll break it into individual images, and using a stacked widget with a QLabel showing the image, since the incoming condition data is integer based.
    --
    The Real Bill

  2. #2
    Join Date
    Sep 2008
    Location
    Munich
    Posts
    32
    Thanked 8 Times in 6 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Show portion of an image

    Hi,

    You could just load the whole image and cut the image into pieces. E.g. QPixmap::copy(size). You want to use QPixmap in the end so that you graphics data resides in the graphics memory. After this I would create a custom widget, where you can set a pixmap list on and only the active index is shown. Please bear in mind that QPixmaps are implicit shared and they always should be created on the stack!

    Qt Code:
    1. public LevelWidget : public QWidget {
    2. void setImages(QList<QPixmap> images) // your cutted images
    3. void setCurrentIndex(int index); // which image to be painted
    4. void paintEvent(QPaintEvent) // paint the current image here
    5. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to show moving image
    By nrabara in forum Newbie
    Replies: 1
    Last Post: 30th December 2009, 08:24
  2. (portion of...) QByteArray to UInt
    By pdoria in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2009, 15:23
  3. download and store/show image
    By peter_hr892h in forum Qt Programming
    Replies: 3
    Last Post: 25th June 2009, 05:16
  4. Displaying a portion of an image
    By tas in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2008, 03:09
  5. Show Image on a QLabel
    By ^NyAw^ in forum Newbie
    Replies: 11
    Last Post: 15th April 2008, 15:45

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.