当前位置:网站首页>Qtreewidget control of QT
Qtreewidget control of QT
2022-07-25 22:41:00 【Things turn at will】
One 、QTreeWidget Use
Adding tree nodes
#include "QtWidgetsApplication1.h"
#include <QtWidgets/QApplication>
#include <QTreeWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//QtWidgetsApplication1 w;
//w.show();
QTreeWidget* tree = new QTreeWidget();
// Add a level one node
QTreeWidgetItem *items1 = new QTreeWidgetItem(tree,
QStringList(QString("num_1")));
QTreeWidgetItem *items2 = new QTreeWidgetItem(tree,
QStringList(QString("num_2")));
QTreeWidgetItem *items3 = new QTreeWidgetItem(tree,
QStringList(QString("num_3")));
// Add secondary nodes
QTreeWidgetItem *item104 = new QTreeWidgetItem(items3,
QStringList(QString("item104")));
QTreeWidgetItem *item145 = new QTreeWidgetItem(item104,
QStringList(QString("item145")));
tree->show();
return a.exec();
}Realization effect

Two 、 Delete node
tree->takeTopLevelItem(1);// Delete index as 1 The node of
// lookup And num_1 Completely consistent items , And back to .
QList<QTreeWidgetItem*> list = tree->findItems("num_1", Qt::MatchFlag::MatchExactly);
// Delete this item
for (auto item : list) {
delete item;
}
3、 ... and 、 Custom style
#include "QtWidgetsApplication1.h"
#include <QtWidgets/QApplication>
#include <QTreeWidget>
#pragma execution_character_set("utf-8")
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//QtWidgetsApplication1 w;
//w.show()
QStringList head;
head << " full name ";
QTreeWidget* tree = new QTreeWidget();
tree->show();
// Set the header
tree->setHeaderLabels(head);
// Add a level one node
head.clear();
head << " Wang Genji ";
QTreeWidgetItem *items1 = new QTreeWidgetItem(tree, head);
head.clear();
head << " Li dachui ";
QTreeWidgetItem *items3 = new QTreeWidgetItem(tree, head);
/// Set the background color
items3->setBackground(0, QBrush(Qt::green));
head.clear();
head << " Lisiji ( Non biological )";
QTreeWidgetItem *item104 = new QTreeWidgetItem(items3, head);
return a.exec();
}
Reference resources :
QT MSVC Chinese compilation error error: C2001: Line breaks in constants _ The blog of Yuanyue villa -CSDN Blog _qt Chinese compilation error
QTreeWidget Qt The most commonly used and best used tree list form _louie_chen The blog of -CSDN Blog _qt Tree list
边栏推荐
- 字符型常量和字符串常量的区别?
- Why should we launch getaverse?
- Pyspark data analysis basis: pyspark.sql.sparksession class method explanation and operation + code display
- 沃达德软件:智慧城市方案
- Kibana~后台启动Kibana之后无法找到进程号
- 力扣解法汇总919-完全二叉树插入器
- Domain oriented model programming
- Array中可以用泛型吗
- [training day13] travel [violence] [dynamic planning]
- 编译器引论
猜你喜欢

Binder原理

Anaconda~Upload did not complete.

【集训DAY15】Boring【树形DP】

Interview question 17.11. word distance ●●
![[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]](/img/46/1c7f6abc74e11c4c2e09655aade223.png)
[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]

关于getchar和scanf的使用示例及注意点

【集训DAY12】X equation 【高精度】【数学】

1000 okaleido tiger launched binance NFT, triggering a rush to buy
![[training day13] Internet [concurrent search]](/img/c6/327095c3ed3a0d4e2b034ff164a7af.png)
[training day13] Internet [concurrent search]

【集训DAY11】Nescafe【贪心】
随机推荐
IFLYTEK smart office book air e-book reader makes my work life healthier
【Leetcode】502.IPO(困难)
Examples and points for attention about the use of getchar and scanf
Short circuit and &, short circuit or |, logic and &, logic or |; Conditional operator
ML-Numpy
Compiler introduction
Select structure if branch structure
[database learning] redis parser & single thread & Model
汇编语言与微机原理实验一、实验二、实验三:分支程序设计/循环程序设计/子程序设计
Array中可以用泛型吗
QT的Tree View Model示例
ECMA 262 12 Lexical Grammer
【集训DAY12】X equation 【高精度】【数学】
【数据库学习】Redis 解析器&&单线程&&模型
平台架构搭建
It's over. I went to work for three months and became bald
Smart S7-200 PLC channel free mapping function block (do_map)
Platform architecture construction
Five constraints and three paradigms
IPv4地址已经完全耗尽,互联网还能正常运转,NAT是最大功臣!