Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Can't set background-color of a QPushButton.
Forum Updated to NodeBB v4.3 + New Features

[Solved] Can't set background-color of a QPushButton.

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 4.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I am having many issues with QSS, but lets take this 1 step at a time. I try to style a QPushButton. Text color is fine, I can change that, but not background-color... I've tried accessing the button in many ways using CSS class, or button itself (#). They can all change the text color fine, but not background color.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Allright, step #1, read updated documentation!

      From http://doc.qt.io/qt-5/stylesheet-reference.html

      bq. Warning: If you only set a background-color on a QPushButton, the background may not appear unless you set the border property to some value. This is because, by default, the QPushButton draws a native border which completely overlaps the background-color. For example,
      @QPushButton { background-color: red; border: none; }@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved