Results 1 to 3 of 3

Thread: Question about semi-transparent child widget

  1. #1
    Join Date
    Nov 2013
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Question about semi-transparent child widget

    Hi,
    I want to draw a semi-transparent child QPushButton on top of a parent Widget which inherits from QGLWidget and repaints itsself every 20ms. The parent widget is implemented in the opensource Project OpenSceneGraph. The following codes are used:
    ***
    ui.setupUi(this);

    ui.pushButton->setAutoFillBackground(true);
    ui.pushButton->setFlat(true);
    ui.pushButton->setStyleSheet("background-color:transparent");
    ***
    then the result is a fully black button on front of the parent widget but not a semi-transparent button(as shown in attachment fig.1). When it comes with the condition of two overlapped QPushButton, the code works well that the upper button is a semi-transparent(fig.2). The follwing two attachments show the result of my code.
    Is there anything wrong with my code settings?(winwods 7 x64, vs 2010,qt 4.8.5)
    QQ图片20131105102738.jpgQQ图片20131105102734.jpg
    Last edited by lpfxyww; 5th November 2013 at 04:04. Reason: miss some info

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about semi-transparent child widget

    try using
    pushButton->setWindowOpacity(0.x);
    or
    QPalette palette ;
    palette.setBrush(QPalette::Background, Qt::transparent);
    button->setPalette(palette);

    with
    button->setAutoFillBackground(false);
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    Join Date
    Nov 2013
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about semi-transparent child widget

    Quote Originally Posted by wagmare View Post
    try using
    pushButton->setWindowOpacity(0.x);
    or
    QPalette palette ;
    palette.setBrush(QPalette::Background, Qt::transparent);
    button->setPalette(palette);

    with
    button->setAutoFillBackground(false);
    Thank you. I tried and it still not work. Also I tried in the src code of OsgEarth samples. Maybe sth else cause this.

Similar Threads

  1. Replies: 3
    Last Post: 18th July 2019, 10:25
  2. Making a chld widget semi transparent:works ony for full transparency.
    By savaliya_ambani in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 7th October 2010, 13:03
  3. Can QDockWidget be semi-transparent?
    By PolyVox in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2009, 20:09
  4. Non-transparent QWidget on semi-transparent parent
    By EuroElessar in forum Qt Programming
    Replies: 0
    Last Post: 29th August 2008, 16:20
  5. Semi-Transparent Background on Widget?
    By JimDaniel in forum Qt Programming
    Replies: 3
    Last Post: 16th January 2008, 18:19

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.