Results 1 to 4 of 4

Thread: How to match a image to QPushButton using stylesheet ?

  1. #1
    Join Date
    Jun 2009
    Location
    Bangalore
    Posts
    21
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Smile How to match a image to QPushButton using stylesheet ?

    Hi,

    I am using Qt Designer 4.6 in windows vista.
    want to set backround image to QPushButton. but my image size is smaller than the button size.

    could anyone help me to fit the image to button size ?
    when I expand the application by dragging, the button size also will change.
    so i want to fix the image to button in any size.

    Thanks in advance

  2. #2
    Join Date
    Dec 2009
    Posts
    19
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to match a image to QPushButton using stylesheet ?

    You can use
    Qt Code:
    1. border-image: url(/url/to/image) 16;
    2. border-width: 16px;
    To copy to clipboard, switch view to plain text mode 
    for buttons in stylesheet. I think border-width should match the second argument of border-image. I don't know exactly how that works and what those numbers mean (since it's been only 2 weeks since I started working with Qt ), but it gives the effect you want.

    Taken from "C++ GUI Programming with Qt 4, Second Edition by Jasmin Blanchette; Mark Summerfield".
    Last edited by nateriver; 23rd December 2009 at 06:20. Reason: I don't know what that '16' stands for either ;)

  3. The following user says thank you to nateriver for this useful post:

    prady (23rd December 2009)

  4. #3
    Join Date
    Jun 2009
    Location
    Bangalore
    Posts
    21
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to match a image to QPushButton using stylesheet ?

    Its working fine for me.

    I just used
    Qt Code:
    1. border-image: url(/url/to/image)
    To copy to clipboard, switch view to plain text mode 

    not used any numbers, or set border-width.

    Thanks.

  5. #4
    Join Date
    Dec 2009
    Posts
    19
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to match a image to QPushButton using stylesheet ?

    Your welcome.

Similar Threads

  1. Adding Image to QPushButton
    By Seema Rao in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 10:06
  2. QPushButton with image - text alignment
    By vladeck in forum Newbie
    Replies: 3
    Last Post: 1st July 2009, 20:20
  3. QPushbutton with background image when disabled
    By soumyadeep_pan in forum Qt Programming
    Replies: 1
    Last Post: 29th May 2009, 16:50
  4. QPushButton Icon Image
    By QbelcorT in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 15:26
  5. Replies: 3
    Last Post: 28th January 2007, 18:24

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.