QT transparent layout

I use the vertical layout (QVBoxLayout) to control the buttons. I would like to make my background color transparent at 50%. Is it possible?

SW

+3
source share
2 answers

Depending on where you want to get the border of the transparent area, you will need to group the buttons into a widget (as SigTerm said), and then you can assign a color either through the palette

QPalette palette = widget->palette();
palette.setColor(QPalette::Window, QColor(100,100,100,100));
widget->setPalette(palette);

or use a stylesheet

widget->setStylesheet("QWidget{background-color: rgba(100,100,100,100);}";

Styles have the advantage that you can style your entire application from one place that is not in the code, and set the application stylesheet through QApplication::setStylesheet(QString)

+4
source

... , Qt, , , QVBoxLayout , , . , , .

, , , , QVBoxLayout .

, , QVBoxLayout, , - " " Qt4 , .

+2

Source: https://habr.com/ru/post/1748663/


All Articles