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. Add multiple background images to a button
QtWS25 Last Chance

Add multiple background images to a button

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.4k 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.
  • S Offline
    S Offline
    Sorin
    wrote on last edited by
    #1

    Lets say that I have 3 images and I want to put them on a button( QToolButton ) one on left, one on center and one on right. How can I do this? Can I do it with stylesheets?

    Thanks!

    There are only 10 types of people in the world: Those who understand binary, and those who don't

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      A button has one background image. You can combine them by code and ad the combined image. But I know no way to put several images in specific places in the background.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sorin
        wrote on last edited by
        #3

        ... so loading images into pixmaps and after that painter.drawPixmap( x,y,w,h ) ...

        There are only 10 types of people in the world: Those who understand binary, and those who don't

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          yep

          load the images into QPIxmap or QImage, create a new QPixmap

          @
          QPixmap newPix(x,y);
          QPainter paint(&newPix);

          paint.drawPixmap(..., pix1);
          paint.drawPixmap(..., pix2);
          paint.drawPixmap(..., pix3);
          
          // use newPix as background
          

          @

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          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