Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to scale QImage or QPixmap to fit the parent Width X Height?

How to scale QImage or QPixmap to fit the parent Width X Height?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heatblazer
    wrote on last edited by
    #1

    Hello,
    I am trying to scale a PNG ( which I am not sure is right ) to match the parent WxH. Here is my code:
    @
    ...
    QImage test3(":/resources/images/test3.png");
    test3 = test3.scaled(width, height, Qt::IgnoreAspectRatio);
    ...
    myScene->setBackgroundBrush(QBrush(test3));
    myScene->setSceneRect(QRectF(0,0,width,height));
    @
    Where "width" and "height" are passed from parent class who calls this code. The result is shown here:
    https://www.flickr.com/photos/heatblazer/15460475363/
    I want the screen to be filled with the background image. As in the examples with Qt::IgnoreAspectRatio is shown - it should fill to max width and height. Also - can I use SVG to achieve the effect without losing quality of the image? And what are the costs for rendering SVG?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved