Unsolved What is the relationship between paintEvent and style sheet of a QWidget?
-
I want to know what is the relationship between paintEvent ann stylesheet of one single widget?I know the QWidget obey Box Model ,so does that mean when we implent the paintEvent() we only draw in the "Content Region" of Box Model ?
-
Hi
StyleSheets are used by QStyle and it drawX functions.
so to use stylesheet in (custom) paintEvent, one must use QStyle to draw.
QPainter itself knows nothing about the stylesheets.void CustomWidget::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); }
Above code makes CustomWidget respect StyleSheet.