Results 1 to 4 of 4

Thread: QPushButton color when clicked

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    17
    Thanked 7 Times in 4 Posts

    Default QPushButton color when clicked

    I have a push button that I want to always look red even when I have done setChecked(true) to keep it depressed.

    I have this:

    Qt Code:
    1. m_fourButton->setStyleSheet(QString("QPushButton {background-color: red;} QPushButton:checked{background-color: red;} QPushButton:pressed {background-color: red;}"));
    To copy to clipboard, switch view to plain text mode 
    I also tried background:red.

    I started with QPalellete which gives me the same results.
    Qt Code:
    1. m_redPalette.setColor(QPalette::Button, Qt::red);
    2. QBrush brush;
    3. brush.setColor(Qt::red);
    4. m_redPalette.setBrush(QPalette::Window, brush);
    To copy to clipboard, switch view to plain text mode 
    and tried everything that Palette would let me for Color Roles.

    The result is that it is red when it is not checked but only the border is red when it is checked (depressed). Is there anything else I can do to make the pressed button red?

    I've attached a zip file with an image of the buttons (it wouldn't let me upload my .bmp file).

    Thanks
    Attached Files Attached Files

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
  •  
Qt is a trademark of The Qt Company.