QDialog border inherited by child QCheckBox
Solved
General and Desktop
-
I create a custom QDialog and specify a border in the stylesheet. The dialog has a QCheckBox that I have increased in size. The dialog border style also gets applied to the QCheckBox .. how can I stop the border being applied to the checkbox?
import sys from PyQt5.QtCore import * from PyQt5.QtWidgets import * class MyDialog(QDialog): def __init__(self, parent=None): super(MyDialog, self).__init__(parent) self.setFixedSize(400, 400) self.setStyleSheet("background-color:#4C535D;border-style:solid;border-color: #E1D8FF;border-width:2px;border-radius:6px") self.myCheckBox = QCheckBox() self.myCheckBox.setStyleSheet("QCheckBox::indicator { width: 30px; height: 30px }") layout = QHBoxLayout() layout.addWidget(self.myCheckBox) self.setLayout(layout) def window(): app = QApplication(sys.argv) w = QWidget() btn = QPushButton(w) btn.setText("Choose Me") btn.move(100,50) btn.clicked.connect(showdialog) w.setWindowTitle("PyQt Dialog demo") w.show() sys.exit(app.exec_()) def showdialog(): dlg = MyDialog() dlg.setWindowTitle("Dialog") dlg.setWindowModality(Qt.ApplicationModal) dlg.exec_() if __name__ == '__main__': window()
-
self.setStyleSheet("MyDialog { background-color:#4C535D; ... }")
I believe should prevent that inheritance?
-