Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Add multiple background images to a button

    General and Desktop
    2
    4
    4100
    Loading More Posts
    • 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
      Sorin last edited by

      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 Reply Quote 0
      • G
        giesbert last edited by

        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 Reply Quote 0
        • S
          Sorin last edited by

          ... 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 Reply Quote 0
          • G
            giesbert last edited by

            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 Reply Quote 0
            • First post
              Last post