QStyleOption opt; opt.initFrom(frame); opt.state |= QStyle::State_Sunken; QPainter painter(frame); style()->drawPrimitive(QStyle::PE_FrameLineEdit, &opt, &painter, frame);
QStyleOptionButton opt; opt.initFrom(button); opt.rect = button->rect(); opt.state |= QStyle::State_On; QPainter painter(button); style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter, button);In this example, we create a QStyleOptionButton object based on a QPushButton widget. We set the widget to an on state and then pass the QStyle::PE_IndicatorCheckBox primitive to the drawPrimitive function to draw a checkbox. Package library: Qt Overall, the drawPrimitive function is an essential part of the QStyle class in Qt and provides developers with the ability to customize the look and feel of Qt applications.