#include#include int main(int argc, char *argv[]) { QApplication app(argc, argv); // Create a new QFrame widget QFrame *frame = new QFrame(); // Set the widget's size and background color frame->setFixedSize(200, 200); frame->setStyleSheet("background-color: yellow"); // Show the frame widget frame->show(); return app.exec(); }
#includePackage library: Qt GUI library (part of the Qt framework)#include #include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); // Create a new QWidget to hold the QFrame and layout QWidget *mainWidget = new QWidget(); // Create a new QFrame widget QFrame *frame = new QFrame(); frame->setFixedSize(200, 200); frame->setStyleSheet("background-color: yellow"); // Create a new QGraphicsDropShadowEffect to add a shadow effect to the QFrame QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect; shadowEffect->setBlurRadius(8); shadowEffect->setOffset(0); shadowEffect->setColor(Qt::black); frame->setGraphicsEffect(shadowEffect); // Create a new QVBoxLayout to add the QFrame to QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(frame); // Set the layout for the main widget and show it mainWidget->setLayout(layout); mainWidget->show(); return app.exec(); }