Results 1 to 9 of 9

Thread: diplay and resize bitmap

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: diplay and resize bitmap

    Thank you very much for your help!

    I was wondering how you resize the loaded image from bitmap file?
    Is the best way to resize the image by forcing it fit onto a widget of a smaller size? Somehow.

    Also, once you have diplayed your bitmap, is it possible to display something over it (for example text) so that the bitmap underneath is still seen? I guess this is a question about layers.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: diplay and resize bitmap

    QPixmap::scaled() or QImage::scaled() are your friends. You can paint over an image as well, if you want, without any layers. If you want layers, you can position one widget over another. Or use QGraphicsView. It really depends what you want to obtain.

  3. The following user says thank you to wysota for this useful post:

    tommy (14th November 2007)

  4. #3
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default thanks wysota

    Thanks wysota!

    Since you so kindly offered your help, I'd like to ask you how you position one widget over another so that both show? Layers would be a good solution. I only know how to show one widget in any given position?
    My goal is to display a bitmap image (QPixmap) and show it. Then draw a circle over it using another layer (display one widget over another, as you suggested). I'd then like to remove the upper layer (the circle) when user checks the check-button and display the layer with the circle again when the user unchecks the check button. Kind of a toggle view.
    My first obstacle is to find a way to display two widgets one over the other so that both show.
    Thanks again.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: thanks wysota

    Quote Originally Posted by tommy View Post
    I'd like to ask you how you position one widget over another so that both show?
    Make one widget child of another.

    display one widget over another, as you suggested
    I didn't suggest anything like that. Your goal seems perfect for QGraphicsView or for subclassing QLabel and reimplementing its paintEvent() to draw the additional circle depending on the state of a property.

  6. The following user says thank you to wysota for this useful post:

    tommy (14th November 2007)

  7. #5
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: diplay and resize bitmap

    Wysota,

    Sorry for another (most likely) stupid question but how do you make one widget a child of another?
    And once you have that achieved, how do you then set them. So far I've been doing this when I display something:

    myLabel->setPixmap(pm);

    But I can't do the same thing twice for the same label?

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: diplay and resize bitmap

    Quote Originally Posted by tommy View Post
    Sorry for another (most likely) stupid question but how do you make one widget a child of another?
    You pass a pointer of the parent widget to the constructor of the child widget.

    But I can't do the same thing twice for the same label?
    You can't, but you can have two labels. But again, based on what you said here, it's not a good approach for you.

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.