#include#include class MyFrameView : public QFrame { public: MyFrameView(QWidget* parent = nullptr) : QFrame(parent) { setFrameStyle(QFrame::Panel | QFrame::Raised); setLineWidth(2); setMidLineWidth(3); } }
#includeThis example creates a custom widget that contains a FrameView and a QLabel inside it. The QLabel is then added to the layout of the FrameView's child widget. The FrameView class is a part of the QtWidgets module of the Qt framework for C++.#include class MyWidget : public QWidget { public: MyWidget(QWidget* parent = nullptr) : QWidget(parent) { QVBoxLayout* layout = new QVBoxLayout(); QLabel* label = new QLabel("Hello, World!", this); MyFrameView* frame = new MyFrameView(this); layout->addWidget(frame); frame->setLayout(new QVBoxLayout); frame->layout()->addWidget(label); setLayout(layout); } }