Results 1 to 5 of 5

Thread: QT push button style sheet issue

  1. #1
    Join Date
    May 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QT push button style sheet issue

    Hi,

    I have a push button and i want to set its style for normal, hover and pressed state. The style sheet code i used is-

    QPushButton#myButton {
    background-image: url(:/image/normal.bmp);
    border: none;
    }

    QPushButton#myButtonressed {
    background-image: url(:/image/pressed.bmp);
    border: none;
    }

    QPushButton#myButton:hover{
    background-image: url(:/image/hover.bmp);
    border: none;
    }

    with this style sheet, normal and hover images are displayed but when i pressed button then button is not showing image for pressed state. Image for hover state is not changed in the pressed state image.

    Any suggestion what i am doing wrong?

  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: QT push button style sheet issue

    You have to change the order of pressed and hover. Then it works.

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

    meraj ansari (13th May 2010)

  4. #3
    Join Date
    May 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT push button style sheet issue

    Thanks Lykurg

  5. #4
    Join Date
    Sep 2013
    Posts
    44
    Thanks
    9
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default Re: QT push button style sheet issue

    it doesn't work for me .
    I used this

    QPushButton#pushButton {
    background-color: red;
    border-style: outset;
    border-width: 2px;
    border-radius: 10px;
    border-color: beige;
    font: bold 14px;
    min-width: 10em;
    padding: 6px;
    }
    QPushButton#pushButtonressed {
    background-color: rgb(224, 0, 0);
    border-style: inset;
    }


    QPushButton#pushButton:hover {
    background-color: rgb(224, 255, 0);
    border-style: inset;
    }

  6. #5
    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: QT push button style sheet issue

    Well, aslo you have to change the order...
    Qt Code:
    1. QPushButton#pushButton:hover {
    2. background-color: rgb(224, 255, 0);
    3. border-style: inset;
    4. }
    5.  
    6. QPushButton#pushButton:pressed {
    7. background-color: rgb(224, 0, 0);
    8. border-style: inset;
    9. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Hareware Push Button
    By mickeyk191 in forum Newbie
    Replies: 2
    Last Post: 26th January 2010, 12:41
  2. Problems with Gradient style used through Style sheet on ARM platform
    By puneet.narsapur in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th January 2010, 12:48
  3. A very small push button
    By Gnurou in forum Qt Programming
    Replies: 2
    Last Post: 15th November 2009, 03:04
  4. style sheet issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2008, 07:18
  5. Push Button problem!!
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2006, 16:31

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.