Results 1 to 7 of 7

Thread: highlighting a QPushButton

  1. #1
    Join Date
    Feb 2009
    Posts
    45
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default highlighting a QPushButton

    - On MAC, I have a qPushButton with a background color. So essentially the whole button is of a certain color.

    - When I tab to this button, I cannot see the button surrounded by a blue highlight as is normally the case when tabbing across widgets. The QPushButton is accessible from the keyboard i.e. I can press enter when I have tabbed to that button, but just can't see the highlight!

    - Is there something that has to be set to push the background color into the 'background' so that the highlight can be seen?

    To set the color I did the following:
    Qt Code:
    1. myButton->setAutoFillBackground(TRUE);
    2. QPalette myPalette = myButton->palette();
    3. myPalette.setColor(QPalette::Button, Qt:Green);
    4. myPalette.setColor(QPalette::Window,Qt:Green);
    5. myButton->setPalette(myPalette);
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: highlighting a QPushButton

    try to play with

    QPalette::Light
    QPalette::Midlight
    QPalette:ark
    QPalette::Mid
    QPalette::Shadow
    QPalette::Highlight

  3. #3
    Join Date
    Feb 2009
    Posts
    45
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: highlighting a QPushButton

    Thanks for the suggestions.
    Tried them but the highlight doesn't appear for the QPushButton when tabbed to.

  4. #4
    Join Date
    Jun 2009
    Posts
    44
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: highlighting a QPushButton

    can I have a transparent button?

    button1->setAutoFillBackground(true);
    QPalette p( button1->palette() );
    p.setBrush( QPalette::Button, Qt::transparent);
    button1->setPalette( p );

    I have done like this but I don't see any changes.
    Last edited by maider; 13th July 2009 at 10:41.

  5. #5
    Join Date
    Jun 2008
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: highlighting a QPushButton

    style sheets could provide cleaner solutions

    QPushButton
    {
    background : transparent;/*background : blue;*/
    border : none;
    }

  6. #6
    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: highlighting a QPushButton

    What if you use QPalette::Window instead of QPalette::Button ?

  7. #7
    Join Date
    Feb 2009
    Posts
    45
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: highlighting a QPushButton

    I tried QPalette::Window but that doesn't change the 'highlight' behavior of the button when tabbed to. This again is a problem seen only on MAC

Similar Threads

  1. Change QPushButton Background Color, Qt4.3
    By Rayven in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2009, 08:14
  2. What is wrong with my code?
    By Dante in forum Qt Programming
    Replies: 27
    Last Post: 6th April 2009, 08:56
  3. QPushButton in QItemDelegate
    By allbabel in forum Qt Programming
    Replies: 0
    Last Post: 2nd April 2009, 12:45
  4. Qpushbutton
    By iamhere in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2008, 05:40
  5. Changing QPushButton text colour with mouseMoveEvent
    By Misenko in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2008, 17:53

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.