#include class SimpleWidget : public QWidget { public: SimpleWidget() { QLabel *label1 = new QLabel("Example"); QCheckBox *chk1 = new QCheckBox("Some Texts"); QCheckBox *chk2 = new QCheckBox(qVersion()); QLabel *label2 = new QLabel("Italic words"); QHBoxLayout *hb = new QHBoxLayout(this); hb->addWidget(label1); hb->addWidget(chk1); hb->addWidget(chk2); QFont f = label2->font(); f.setItalic(true); label2->setFont(f); hb->addWidget(label2); } }; int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QGraphicsScene s(QRect(0, 0, 400, 200)); QGraphicsProxyWidget *pw = s.addWidget(new SimpleWidget()); pw->setPos(1, 1); QGraphicsView *v = new QGraphicsView(); v->setViewport(new QOpenGLWidget()); v->resize(405, 200); v->setScene(&s); v->show(); app.exec(); }