Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QtWidgets>
- int main (int argc, char** argv) {
- QApplication app(argc, argv);
- QWidget wgt;
- QLabel lbl("Label");
- QStringList lst;
- QListWidget lwg;
- QListWidgetItem* pitem = 0;
- lwg.setIconSize(QSize(48, 48));
- lst << "linux" << "windows" << "macos" << "os2";
- foreach(QString str, lst) {
- pitem = new QListWidgetItem(str, &lwg);
- pitem->setIcon(QPixmap(str + ".jpg"));
- }
- QObject::connect(&lwg, SIGNAL(itemActivated(QListWidgetItem*)),
- &lbl, SLOT(setText(lwg.currentItem()->text()));
- //Layout
- QVBoxLayout* pvbxLayout = new QVBoxLayout;
- pvbxLayout->addWidget(&lwg);
- pvbxLayout->addWidget(&lbl);
- wgt.setLayout(pvbxLayout);
- wgt.show();
- return app.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment