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. Setting layers of QPixmaps on a QGraphicsItem?
Qt 6.11 is out! See what's new in the release blog

Setting layers of QPixmaps on a QGraphicsItem?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 637 Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I have this code:

    @QBrush newbrush;

    newbrush.setTexture((QPixmap(":/pics/background.png")).scaled(50,50,Qt::KeepAspectRatio, Qt::FastTransformation));

    painter->setBrush(newbrush);

    painter->drawPixmap(0,0,(QPixmap(":/pics/character.png")).scaled(50,50,Qt::KeepAspectRatio, Qt::FastTransformation));

    painter->drawRoundedRect(0,0,50,50,5,5);@

    It's messy, yes, but this is just testing around. So basically that's in a private function of a QGraphicsItem that displays a rectangle. Ideally I would like to have the newbrush as a background texture and then add the other pixmap on top of the background, to make it look like I have a character on top of a texture. This works to some degree only. When I run that code, it draws the newbrush but not the character. When I set lines 3 and 5 into comments, it draws the character. So this makes me think that it draws the character under the background. How can I make it so that background is drawn on to the rectangle and then the character is drawn on top of the background?

    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