// main.cpp #include #include #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); // Create the top QWidget QWidget *top = new QWidget; QGridLayout *layout = new QGridLayout(top); top->setMinimumSize(100,150); // Create and populate the QComboBox QComboBox *comboBox = new QComboBox; comboBox->addItem("Item 1"); comboBox->addItem("Item 2"); comboBox->addItem("Item 3"); comboBox->addItem("Item 4"); comboBox->addItem("Item 5"); layout->addWidget(comboBox, 0, 0); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding), 1, 0); top->setLayout(layout); // Create QGraphicsView and QGraphicsScene QGraphicsScene *scene = new QGraphicsScene; QGraphicsView *view = new QGraphicsView(scene); // Add the top widget to the scene using QGraphicsProxyWidget QGraphicsProxyWidget *proxy = scene->addWidget(top); view->show(); return a.exec(); }