当前位置:网站首页>QT table display data
QT table display data
2022-06-11 07:28:00 【Fantastical Yu ruiyin】
Environmental statement
Qt edition :5.12 Mingw32
operating system :win10
Implemented function
Qt Use Table Control to display data
Go straight to the code
The header file
//wigth.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QStandardItemModel>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = nullptr);
~Widget();
private:
Ui::Widget *ui;
QStandardItemModel *model;
void addLinemessage(QStringList list,int line);
};
#endif // WIDGET_H
//wigth.cpp
#include "widget.h"
#include "ui_widget.h"
#include <QStandardItem>
#include <QStringList>
void Widget::addLinemessage(QStringList list,int line)
{
for(int i=0;i<list.size();i++)
{
model->setItem(line,i,new QStandardItem(list.at(i)));
}
}
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
model=new QStandardItemModel();
ui->tableView->setModel(model);
QStringList list;
list<<" full name "<<" class "<<" Gender "<<" Age ";
for(int i=0;i<list.size();i++)
{
model->setHorizontalHeaderItem(i,new QStandardItem(list.at(i)));
ui->tableView->setColumnWidth(i,100);
}
QStringList list1;
list1<<" Yu ruiyin "<<" Mechanical shift 1 "<<" male "<<"25";
addLinemessage(list1,0);
}
Widget::~Widget()
{
delete ui;
}
Interface display
The left and right controls are QTableView.

边栏推荐
- 【Oracle 数据库】奶妈式教程day03 排序查询
- Sdl-2 thread logic
- Modular notes
- QT interface nested movement based on qscrollarea
- 213. house raiding II
- 10 advanced concepts that must be understood in learning SQL
- P3172 [cqoi2015] data selection (Mobius inversion + Du Jiao sieve)
- Leetcode-104. Maximum Depth of Binary Tree
- [并发进阶]——线程池总结
- The maximum number of divisors of numbers in the int range is 1536
猜你喜欢

Building a full-featured NAS server with raspberry pie (05): playing with video and audio & sorting out movies

Multi thread review summary parsing volatile keyword

一、SQLServer2008安装(带密码)、创建数据库、C#窗体项目测试

学 SQL 必须了解的10个高级概念

CMAP of Matplotlib
![[analysis of STL source code] summary notes (6): Design of iterator and magical traits](/img/57/eaf02e880d205c5912f353609c9520.png)
[analysis of STL source code] summary notes (6): Design of iterator and magical traits

10 advanced concepts that must be understood in learning SQL

Leetcode-104. Maximum Depth of Binary Tree

Mobile console Gobang (first draft of detailed design)

JVM学习记录(七)——类加载过程与双亲委派模型
随机推荐
P3172 [cqoi2015] data selection (Mobius inversion + Du Jiao sieve)
QT interface nested movement based on qscrollarea
【CF#388 (Div. 2)】A. Bachgold Problem
Leetcode-9. Palindrome Numbber
正则表达式匹配
C language judging big end and small end [consortium or pointer] big end and small end conversion
MS office level II wrong question record [8]
P3811 [template] multiplicative inverse
Decimal to binary
12. integer to Roman numeral
Senior openstacker - Bloomberg, vexxhost upgraded to gold member of openinfra Foundation
Sdl-3 YUV playback
Server parameter adjustment record
Matplotlib, set coordinate scale size, font / set legend size and font / set vertical and horizontal coordinate name, font and size
big.js--使用/实例
webserver
No response from win10 explorer when dragging files
Summary of written test questions of shopee 2021 autumn recruitment
Create a form whose client area is 800 pixels by 600 pixels
P1390 sum of common divisors (Mobius inversion)