How to customize layout with CSS
-
Hi and welcome to devnet,
What layout ?
What CSS ?
What are you trying to achieve ? -
Thank you.
I added some widgets inside a Layout and i would like to customize the Layout to be able to add border and background but it not working.
# Inside my main self.hLayout = QHBoxLayout() self.hLayout.setObjectName("hLayout") self.hLayout.addWidget(self.btn_menu) # Inside the stylesheet added to my QMainWindow ( self.w ) self.w.setStyleSheet(css.MAIN) MAIN = """ QHBoxLayout#hLayout { background: red; } QPushButton#btn_menu { margin-left: 5px; background: white; }
The CSS doesn't work on the layout selector but working on the QPushButton selector. What is the problem ? Layouts can't be customize ?
-
Thank you.
I added some widgets inside a Layout and i would like to customize the Layout to be able to add border and background but it not working.
# Inside my main self.hLayout = QHBoxLayout() self.hLayout.setObjectName("hLayout") self.hLayout.addWidget(self.btn_menu) # Inside the stylesheet added to my QMainWindow ( self.w ) self.w.setStyleSheet(css.MAIN) MAIN = """ QHBoxLayout#hLayout { background: red; } QPushButton#btn_menu { margin-left: 5px; background: white; }
The CSS doesn't work on the layout selector but working on the QPushButton selector. What is the problem ? Layouts can't be customize ?
-
Thank you.
I added some widgets inside a Layout and i would like to customize the Layout to be able to add border and background but it not working.
# Inside my main self.hLayout = QHBoxLayout() self.hLayout.setObjectName("hLayout") self.hLayout.addWidget(self.btn_menu) # Inside the stylesheet added to my QMainWindow ( self.w ) self.w.setStyleSheet(css.MAIN) MAIN = """ QHBoxLayout#hLayout { background: red; } QPushButton#btn_menu { margin-left: 5px; background: white; }
The CSS doesn't work on the layout selector but working on the QPushButton selector. What is the problem ? Layouts can't be customize ?
-
-
@Pl45m4
Yes, but then how does the OP get the layout stuff applied to the widgets which are now inside a singleQFrame
to which the layout applies, instead of to each widget?- MainWidget / Window with layout
- Frame
- Layout with stuff
- Frame
Or even multiple QFrames around each button. Instead of adding the widget to the layout directly, add a QFrame and place widget inside frame.
IDK :) This was the first thing that came to my mind
@zonixo
Setting the background color to each widget instead of whole layout wont work for you? - MainWidget / Window with layout
-
- MainWidget / Window with layout
- Frame
- Layout with stuff
- Frame
Or even multiple QFrames around each button. Instead of adding the widget to the layout directly, add a QFrame and place widget inside frame.
IDK :) This was the first thing that came to my mind
@zonixo
Setting the background color to each widget instead of whole layout wont work for you? - MainWidget / Window with layout
-
This post is deleted!
-
This post is deleted!