便捷部件类
QListWidget listWidget; //添加项目 new QListWidgetItem("**",&listWidget); QListWidgetItem *listWidgetItem = new QListWidgetItem; listWidgetItem->setText("**"); QPixmap pixmap(50,50); pixmap.fill(Qt::blue); listWidgetItem->setIcon(QIcon(pixmap)); listWidgetItem->setToolTip("*****"); //将部件插入项目 listWidget.insertItem(1,listWidgetItem); //将部件设置为降序排序 listWidget.sortItems(Qt::DescendingOrder); listWidget.show(); QTreeWidget treeWidget; //设置列数 treeWidget.setColumnCount(2); QStringList headers; headers<<"*****"<<"*****"; //设置头 treeWidget.setHeaderLabels(headers); //添加项目 QTreeWidgetItem *item1 = new QTreeWidgetItem(&treeWidget); item1->setText(0,"*****"); QTreeWidgetItem *item2 = new QTreeWidgetItem(item1); item2->setText(0,"*****"); item2->setText(1,"*****"); //添加项目 QTreeWidgetItem *item3 = new QTreeWidgetItem(&treeWidget,item1); item3->setText(0,"***"); treeWidget.show(); //创建表格部件 QTableWidget tableWidget(3,2); QTableWidgetItem *tablewidgetItem = new QTableWidgetItem("com"); tableWidget.setItem(1,1,tablewidgetItem); //创建表格项目,作为表头 QTableWidgetItem* headerV = new QTableWidgetItem("cat"); tableWidget.setVerticalHeaderItem(0,headerV); QTableWidgetItem *headerH = new QTableWidgetItem("what"); tableWidget.setHorizontalHeaderItem(0,headerH); tableWidget.show();