Results 1 to 3 of 3

Thread: My button's color seems transparent in QtDesigner but why?

  1. #1
    Join Date
    Mar 2017
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default My button's color seems transparent in QtDesigner but why?

    I'm using QTDesigner 5.15.8 and trying to color buttons.

    color.png

    I have inserted one button and frame on my mainwindow. Here is the stylesheet code of mainwindow

    Qt Code:
    1. background-color: red;
    2. }
    3. background-color: red;
    4. }
    To copy to clipboard, switch view to plain text mode 

    They are same but as you see they look different.

    I couldnt find why it happened but it happens even if I created a new project...

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,243
    Thanks
    303
    Thanked 866 Times in 853 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: My button's color seems transparent in QtDesigner but why?

    This is probably what is happening (from the Qt Style Sheets docs):

    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; }
    See Customizing QPushButton for an example.
    So try also setting "border: none".

    Note that QPushButton customization can also take into account the state of the button (pressed, flat, default, disabled, checked, etc.).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    bladekel (28th October 2024)

  4. #3
    Join Date
    Mar 2017
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: My button's color seems transparent in QtDesigner but why?

    This is the exact solution. Thanks....

Similar Threads

  1. Why my text entry scrollbar track color is transparent?
    By Ishaq Khan in forum Qt Programming
    Replies: 1
    Last Post: 7th July 2019, 12:27
  2. Transparent button icon
    By alenn.masic in forum Qt Programming
    Replies: 2
    Last Post: 4th November 2012, 12:35
  3. Replies: 0
    Last Post: 25th August 2010, 18:39
  4. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 23:25
  5. clean with transparent color
    By Lele in forum Qt Programming
    Replies: 9
    Last Post: 28th October 2007, 14:45

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.