Important: Please read the Qt Code of Conduct -

Add multiple background images to a button

  • 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?


  • 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.

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

  • 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


Log in to reply