1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| #include "widget.h" #include "ui_widget.h"
Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); initListWidget(); }
Widget::~Widget() { delete ui; }
void Widget::initListWidget() { ui->listWidget->setCurrentRow(2);
QStringList StrListHeader; StrListHeader << QString("选中") << QString("序号") << QString("文件名"); new QListWidgetItem(tr("Oak"), ui->listWidget); new QListWidgetItem(tr("Fir"), ui->listWidget); new QListWidgetItem(tr("Pine"), ui->listWidget);
QListWidgetItem *ListItem = new QListWidgetItem;
QListWidgetItem *WContainerItem = new QListWidgetItem(ui->listWidget); QWidget *WContainer = new QWidget(ui->listWidget); QGridLayout*Glayout = new QGridLayout;
QLineEdit *lineEdit = new QLineEdit; QLineEdit *lineEdit_1 = new QLineEdit; QToolButton *toolButton = new QToolButton; QRadioButton *radioButton = new QRadioButton; QRadioButton *radioButton_1 = new QRadioButton;
Glayout->addWidget(lineEdit,0,0); Glayout->addWidget(radioButton,0,1); Glayout->addWidget(lineEdit_1,0,2); Glayout->addWidget(radioButton_1,0,3);
WContainer->setLayout(Glayout);
WContainerItem->setSizeHint(QSize(40,40));
ui->listWidget->setItemWidget(WContainerItem, WContainer);
}
|