I want the child widget to just appear in the center of the parent widget with a horizontal pink stripe. But the widget of the parent becomes very small
from PySide6 import QtWidgets, QtGui
import sys
class WidgetA(QtWidgets.QWidget):
def __init__(self):
super(WidgetA, self).__init__()
self.wb = WidgetB()
vbox = QtWidgets.QVBoxLayout()
hbox = QtWidgets.QHBoxLayout()
hbox.addWidget(self.wb)
vbox.addLayout(hbox)
self.setLayout(vbox)
class WidgetB(QtWidgets.QWidget):
def __init__(self):
super(WidgetB, self).__init__()
palette = self.palette()
palette.setColor(QtGui.QPalette.Window, QtGui.QColor("#ff00ff"))
self.setPalette(palette)
app = QtWidgets.QApplication()
window = WidgetA()
window.show()
sys.exit(app.exec())
If I have not written something, or something is not clear in my question, then ask, I will supplement it
source https://stackoverflow.com/questions/70825736/how-to-make-the-parent-widget-not-adjust-to-the-child
Comments
Post a Comment