MainWindow
::MainWindow( QWidget* p
) :
{
w1->setFixedSize( 100, 100 );
w1->setStyleSheet( "background: rgba(255, 0, 0, 127);" ); // 50% transparent
l->move( 0, 80 );
l->setStyleSheet( "background: none;" ); // remove inherited background
w2->setFixedSize( 100, 100 );
w2->move( 50, 50 );
w2->setStyleSheet( "background: rgba(0, 255, 0, 127);" ); // 50% transparent
w1->show();
w2->show();
}
MainWindow::MainWindow( QWidget* p )
:
QMainWindow( p )
{
QWidget* w1 = new QWidget( this );
w1->setFixedSize( 100, 100 );
w1->setStyleSheet( "background: rgba(255, 0, 0, 127);" ); // 50% transparent
QLabel* l = new QLabel( "test test test1", w1 );
l->move( 0, 80 );
l->setStyleSheet( "background: none;" ); // remove inherited background
QWidget* w2 = new QWidget( this );
w2->setFixedSize( 100, 100 );
w2->move( 50, 50 );
w2->setStyleSheet( "background: rgba(0, 255, 0, 127);" ); // 50% transparent
w1->show();
w2->show();
}
To copy to clipboard, switch view to plain text mode
This transparency applies only to widget background, so ie button will still be 100% opaque.
Bookmarks