Results 1 to 11 of 11

Thread: Stylesheet is not working for QToolButton

  1. #1
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Stylesheet is not working for QToolButton

    Hi Every body

    I'm tryng to apply stylesheet for both pushbutton and tool button through qss file. Below i've posted the qss file. its working fine for QPushButton. but not working for QtoolButton. Plz help me.


    Qt Code:
    1. {
    2. image: url(":/resource/Icons/Popup_BTN_N.png");
    3. }
    4.  
    5. QPushButton:pressed
    6. {
    7. image: url(":/resource/Icons/Popup_BTN_D.png");
    8. }
    9.  
    10. QPushButton:focused
    11. {
    12. image: url(":/resource/Icons/Popup_BTN_F.png");
    13. }
    14.  
    15. {
    16. image: url(":/resource/Icons/Popup_BTN_F.png");
    17. }
    18.  
    19.  
    20. {
    21. image: url(":/resource/Icons/Contents_Monitor_Close_Icon_N.png");
    22. }
    23.  
    24.  
    25. QToolButton:pressed
    26. {
    27. bimage: url(":/resource/Icons/Contents_Monitor_Close_Icon_D.png");
    28. }
    29.  
    30.  
    31. QToolButton:focused
    32. {
    33. image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
    34. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Stylesheet is not working for QToolButton

    Hi,

    What about QToolButton::indicator?

  3. #3
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Stylesheet is not working for QToolButton

    Quote Originally Posted by zgulser View Post
    Hi,

    What about QToolButton::indicator?
    Shall i add it like

    QToolButton:indicator
    {
    image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
    }

    My need is to change the colors while it is focussing or selected or neutral.

    Is above code right???

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Stylesheet is not working for QToolButton

    Yeah I meant you need to add it like you showed.

    But if you want to change the background color, use "background-color" property not "image".

  5. #5
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Stylesheet is not working for QToolButton

    Quote Originally Posted by zgulser View Post
    Yeah I meant you need to add it like you showed.

    But if you want to change the background color, use "background-color" property not "image".
    i did like this. but its not working. i ve some png to apply toolbutton. it should change during different state like, pressed, or hovered.
    how to do it??

  6. #6
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Stylesheet is not working for QToolButton

    Quote Originally Posted by sudhansu View Post
    i did like this. but its not working. i ve some png to apply toolbutton. it should change during different state like, pressed, or hovered.
    how to do it??
    Hi ALl
    I'm still stuck in the problem. Please tell me how to solve it.
    Thank you all.

  7. #7
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Stylesheet is not working for QToolButton

    Hi,

    I guess it'll work now..

    QToolButtonressed{

    border: 2px solid #8f8f91;
    border-radius: 6px; // not necessary
    background-color:red;

    }

  8. #8
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Stylesheet is not working for QToolButton

    Quote Originally Posted by zgulser View Post
    Hi,

    I guess it'll work now..

    QToolButtonressed{

    border: 2px solid #8f8f91;
    border-radius: 6px; // not necessary
    background-color:red;

    }
    Thank you very much for the reply. But i need to change the background images. I ve different images for mouse hovering or button focused, neutral and selected . How to do it?

  9. #9
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Stylesheet is not working for QToolButton

    Brother then just change as the following;

    QToolButton:hover
    {
    border: 2px solid #8f8f91;
    border-radius: 6px; // not necessary
    image: url("yourimage.jpg");
    }

    This is for hover. Apply it to other pseudo states by just replacing hover with selected, focused or something.

  10. #10
    Join Date
    Oct 2009
    Posts
    105
    Thanked 4 Times in 2 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Stylesheet is not working for QToolButton

    Quote Originally Posted by zgulser View Post
    Brother then just change as the following;

    QToolButton:hover
    {
    border: 2px solid #8f8f91;
    border-radius: 6px; // not necessary
    image: url("yourimage.jpg");
    }

    This is for hover. Apply it to other pseudo states by just replacing hover with selected, focused or something.
    No its not working this way. I tried like

    Qt Code:
    1. {
    2. image: url(":/resource/Icons/Contents_Monitor_Close_Icon_N.png");
    3. }
    4.  
    5.  
    6. QToolButton:pressed
    7. {
    8. image: url(":/resource/Icons/Contents_Monitor_Close_Icon_D.png");
    9. }
    10.  
    11.  
    12. QToolButton:focused
    13. {
    14. image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
    15. }
    16.  
    17.  
    18. QToolButton::indicator
    19. {
    20. image: url(":/resource/Icons/Contents_Monitor_Close_Icon_F.png");
    21. }
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Stylesheet is not working for QToolButton

    QToolButton:hover
    {
    border: 2px solid #8f8f91;
    border-radius: 6px; // not necessary
    background- image: url("yourimage.jpg");
    }

    but make sure to run the program. It's not shown in the designer since it's linked in the source.

Similar Threads

  1. QToolbutton:checked -> QIcon:selected not working
    By tomf in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2010, 21:17
  2. TabOrder for QToolButton not working
    By gren15 in forum Qt Tools
    Replies: 6
    Last Post: 28th May 2009, 16:38
  3. QListView StyleSheet NOT WORKING!
    By QbelcorT in forum Qt Programming
    Replies: 5
    Last Post: 22nd March 2009, 08:38
  4. Need help with QToolButton
    By philipp1 in forum Qt Programming
    Replies: 12
    Last Post: 27th October 2006, 15:37
  5. Need help with QToolButton
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 22nd April 2006, 14:55

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.