Results 1 to 9 of 9

Thread: QToolButton customization / skinning

  1. #1
    Join Date
    Feb 2010
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QToolButton customization / skinning

    Hi,

    I use some QToolButtons (text under icon) in my program. Now I want to do two things:

    1. specify a different icon over stylesheet
    2. draw a colored rounded, filled rectangle only as text background (not the image)

    Has somebody an idea, how to achieve this or has a link to a code snippet?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QToolButton customization / skinning

    Quote Originally Posted by Treggie View Post
    1. specify a different icon over stylesheet
    use qproperty-icon.

  3. #3
    Join Date
    Feb 2010
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton customization / skinning

    Hey man, thanks for the info! Learned a "trick" more again

    Now I'm only searching for a way to paint only behind the text. I thought, that I could use a gradient (can I draw rounded reactangles this way?), which leaves the image area free and starts somewhere in the middle of the button. But all attempts until now don't work

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QToolButton customization / skinning

    Quote Originally Posted by Treggie View Post
    I'm only searching for a way to paint only behind the text. I thought, that I could use a gradient (can I draw rounded reactangles this way?), which leaves the image area free and starts somewhere in the middle of the button. But all attempts until now don't work
    I don't know a way to do that with style sheets. I would say you have to subclass and do some painting by yourown.

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton customization / skinning

    Now I'm only searching for a way to paint only behind the text.
    Do you mean the background? Read about background in Qt style sheets

  6. #6
    Join Date
    Feb 2010
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton customization / skinning

    Correct ... I mean the background. Have already read the stylesheet docu, but haven't found a way to draw only half the background with a Gradient and keep the other half part transparent or as it is.

  7. #7
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton customization / skinning

    hi
    for setting a image using stylesheet
    Qt Code:
    1. t->setStyleSheet("background-image: url(computer.gif)");
    To copy to clipboard, switch view to plain text mode 


    for setting a transparent in a stylesheet
    Qt Code:
    1. background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6666FF, stop: 0.7 #99CCFF , stop: 1 #CCCCFF);
    To copy to clipboard, switch view to plain text mode 

    work it around, u may find a solution. (im not sure ,it helps or not)
    hope it helps

    Bala

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QToolButton customization / skinning

    Quote Originally Posted by Treggie View Post
    Correct ... I mean the background.
    than write it next time....
    Have already read the stylesheet docu, but haven't found a way to draw only half the background with a Gradient and keep the other half part transparent or as it is.
    Then use a gradient which is from 0.0 to 0.5 transparent and for 0.500000000000000000000000000000000000000000000000 000000000000000000000001 to 1.0 make your colours. How to use gradient has BalaQt written and all that are wounderfull explained in the docus.

  9. #9
    Join Date
    Feb 2010
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QToolButton customization / skinning

    Hi Lykurg ... why so aggressive? You helped me with the first part of the question (the hint to the qproperty was helpful indeed). For the second part (as noted ... and written) in my initial question I will try the gradient (which I already know).

Similar Threads

  1. QTabWidget customization
    By asafzakay in forum Qt Programming
    Replies: 16
    Last Post: 26th November 2017, 11:01
  2. QSqlTableModel column customization
    By kishore7771 in forum Qt Programming
    Replies: 1
    Last Post: 16th October 2009, 09:07
  3. Window customization
    By Kostanev in forum Qt Programming
    Replies: 11
    Last Post: 14th August 2008, 18:04
  4. Replies: 1
    Last Post: 10th July 2008, 17:59
  5. Layout runtime customization
    By altVis in forum Qt Programming
    Replies: 3
    Last Post: 18th April 2008, 07:59

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.