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. Remove gradient from QPushButton
Forum Updated to NodeBB v4.3 + New Features

Remove gradient from QPushButton

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 288 Views
  • 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.
  • S Offline
    S Offline
    shreya_agrawal
    wrote on last edited by
    #1

    This question might sound a bit stupid, but I was unable to find any proper solution for it.
    I have a QPushButton. When I directly give it style using:
    myButton->setStyleSheet();
    I get the required color in it. But, when I set its object name and then apply stylesheet to that object name in my qss file, I get a default gradient and the color is also changed a bit. I am using the same bgr values in both. Is there any way around it? I tried the setAutoFillBackground() property, but it still doesn't work.

    Here is my qss code:

    #myButton {
    background-color: rgb(199, 255, 155);
    border: 1px solid black;
    }

    S 1 Reply Last reply
    0
    • S shreya_agrawal deleted this topic on
    • S shreya_agrawal restored this topic on
    • S shreya_agrawal

      This question might sound a bit stupid, but I was unable to find any proper solution for it.
      I have a QPushButton. When I directly give it style using:
      myButton->setStyleSheet();
      I get the required color in it. But, when I set its object name and then apply stylesheet to that object name in my qss file, I get a default gradient and the color is also changed a bit. I am using the same bgr values in both. Is there any way around it? I tried the setAutoFillBackground() property, but it still doesn't work.

      Here is my qss code:

      #myButton {
      background-color: rgb(199, 255, 155);
      border: 1px solid black;
      }

      S Offline
      S Offline
      shreya_agrawal
      wrote on last edited by shreya_agrawal
      #2

      @shreya_agrawal

      This is how I got rid of the gradient:
      background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 your_color, stop: 1 your_color);

      1 Reply Last reply
      0
      • S shreya_agrawal has marked this topic as solved on

      • Login

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