当前位置:网站首页>QT: list box, table, tree control
QT: list box, table, tree control
2022-07-26 07:15:00 【@Bu Xiangwan spicy】
One 、 List box
#include "widget.h"
#include <QApplication>
#include <QListWidget>
#include <QStringList>
#include <QTableWidget>
#include <QTreeWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QListWidget lw(&w);
lw.move(100,200);
lw.resize(100,200);
lw.addItem(" Baidu ");
lw.addItem(new QListWidgetItem(" tencent "));
QStringList qstr;
qstr << " Alibaba " << " Bytes to beat " ;
lw.addItems(QStringList() << " Alibaba " << " Bytes to beat ");
QObject::connect(&lw,&QListWidget::itemDoubleClicked,&lw,&QListWidget::clear);
w.show();
return a.exec();
}
Output :

Two 、 form
#include "widget.h"
#include <QApplication>
#include <QListWidget>
#include <QStringList>
#include <QTableWidget>
#include <QTreeWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
QTableWidget tw(3,3,&w);
tw.move(100,100);
tw.resize(500,400);
tw.setHorizontalHeaderLabels(QStringList() << " Enterprises " << " website " << " founder ");
tw.setItem(0,0,new QTableWidgetItem(" Baidu "));
tw.setItem(0,1,new QTableWidgetItem("www.baidu.com"));
tw.setItem(0,2,new QTableWidgetItem(" Robin Li "));
tw.setItem(1,0,new QTableWidgetItem(" tencent "));
tw.setItem(1,1,new QTableWidgetItem("www.qq.com"));
tw.setItem(1,2,new QTableWidgetItem(" ma "));
tw.setItem(2,0,new QTableWidgetItem(" Alibaba "));
tw.setItem(2,1,new QTableWidgetItem("www.1688.com"));
tw.setItem(2,2,new QTableWidgetItem(" Jack ma, "));
tw.setRowCount(tw.rowCount() + 1);
tw.setItem(3,0,new QTableWidgetItem(" Bytes to beat "));
tw.setItem(3,1,new QTableWidgetItem("www.bytedance.com"));
tw.setItem(3,2,new QTableWidgetItem(" Zhang Yiming "));
QObject::connect(&tw,&QTableWidget::cellDoubleClicked,&tw,&QTableWidget::removeRow);
w.show();
return a.exec();
}Output :

3、 ... and 、 Tree control
#include "widget.h"
#include <QApplication>
#include <QListWidget>
#include <QStringList>
#include <QTableWidget>
#include <QTreeWidget>
tw.move(100,100);
tw.resize(300,200);
QTreeWidgetItem topItem(&tw);
topItem.setText(0," website ");
//tw.addTopLevelItem(&topItem);
QTreeWidgetItem Bd(&topItem,QStringList() << " Baidu ");
QTreeWidgetItem BdUrl(&Bd,QStringList() << "www.baidu.com");
QTreeWidgetItem Tx(&topItem,QStringList() << " tencent ");
QTreeWidgetItem TxUrl(&Tx,QStringList() << "www.qq.com");
w.show();
return a.exec();
}
Output :

边栏推荐
- < II> ObjectARX development: create and edit basic graphic objects
- Manifest merger failed with multiple errors, see logs
- Image annotation software reference
- Tips when entering a formula in latex
- 又是一年开源之夏,1.2万项目奖金等你来拿!
- [749. Isolate virus]
- MySql 中应该如何将多行数据转为多列数据
- To do list application vikunja
- Business secret series -- Talking about the evaluation of commercial passwords from the perspective of Party A and Party B (I)
- Difference between shape and size ()
猜你喜欢

Realization of LED water lamp based on C51

成为 Apache 贡献者,So easy!
![Rgb-t tracking - [dataset benchmark] gtot / rgbt210 / rgbt234 / vot-2019-2020 / laser / VTUAV](/img/10/40d02da10a6f6779635dc820c074c6.png)
Rgb-t tracking - [dataset benchmark] gtot / rgbt210 / rgbt234 / vot-2019-2020 / laser / VTUAV

How to use Hyper-V in win10 Home Edition

How can man Bang write a new footnote to the value of the industry's first social responsibility report?

Yolov5 improvements: add attention mechanism (video tutorial)

Contents mismatch at: 08000000H (Flash=FFH Required=00H) ! Too many errors to display !

Question: can't download sh shellcheck Please install it manually and some commands of shell script
![[untitled] reprint](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)
[untitled] reprint

File server fastdfs
随机推荐
No .egg-info directory found in xxx\pip-pip-egg-info-mq
File server fastdfs
Realization of LED water lamp based on C51
PG operation and maintenance -- logical backup and physical backup practice
20220725 convolution in automatic control principle
基于C51实现led流水灯
Event loop in browser
Drools (3): drools basic syntax (1)
Opencv learn resize and crop
To do list application vikunja
centos7下的MySQL57版本,遇到一个问题不理解有知道的大shen告知
A guide for you to fully use TS
Image annotation software reference
anaconda安装教程-手把手教你安装
Flame diagram analysis Flink backpressure
Analysis of strong tennis cup 2021 PWN competition -- baby_ diary
Now the metauniverse is no longer an existence that is only applied to the social field
shape 和 size() 区别
C51与MDK共存 Keil5安装教程
【一库】妙啊!这个库组织npm脚本简直爆炸!