Results 1 to 6 of 6

Thread: Issues writing a simple image viewer class

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Issues writing a simple image viewer class

    Quote Originally Posted by Lykurg View Post
    Ok,

    I don't have read all, but why do you want to do all the nasty work with the size thing by your own? Let Qt do the dirty work for you!

    Since - I have said this this day already in an other post - QPixmap is a QPaintDevice use it! What I mean is:
    • store the given pixmap (gpm)
    • paint the gpm with transformations on a new pixmap (npm) you create
    • set this pixmap (npm) to the label

    By doing so, you don't have to take care about all the layout stuff...
    Lykurg
    I've thought about that... but then I would have to store two copies of the image (one in my pixmap and one in the QLabel). Also I would have to copy the pixmap to the QLabel whenever I made a new transformation (I would imagine this would be an expensive operation if I were to animate my transformations).

    By doing it in the method I'm attempting I don't have any of those issues. I store one pixmap... and I paint that one pixmap with the desired transformations onto the widget.

    Instead of suggesting other options I would prefer some help with why my method is not working (unless people have suggestions that don't include QLabel )

  2. #2
    Join Date
    Aug 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Issues writing a simple image viewer class

    Turns out my issue was really trivial. When adding an image to a scroll area you need to call setWidgetResizable to true... otherwise the widget is never resized:
    Qt Code:
    1. m_scrollArea->setWidgetResizable(true);
    To copy to clipboard, switch view to plain text mode 

    It now displays the image correctly (mostly that is... there are still some minor issues to resolve, but I think I can work those out).

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.