当前位置:网站首页>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.

边栏推荐
- P3327 [sdoi2015] approximate sum (Mobius inversion + formula)
- JVM learning record (VII) -- class loading process and parental delegation model
- C language judging big end and small end [consortium or pointer] big end and small end conversion
- @Jsonproperty annotation
- Mobile console Gobang (first draft of detailed design)
- [STL source code analysis] summary notes (1): Opening
- Sdl-4 PCM playback
- [analysis of STL source code] summary notes (3): vector introduction
- Education expert wangzhongze shared his experience for many years: family education is not a vassal
- Notes on learning Es5 and ES6
猜你喜欢

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

Listen to the left width of the browser to calculate the distance

Modular notes

Multi thread review summary parsing volatile keyword
![[analysis of STL source code] summary note (4): behind the scenes hero allocator](/img/b9/cf53fd8f933042ff65844d61eca55e.jpg)
[analysis of STL source code] summary note (4): behind the scenes hero allocator
![[STL source code analysis] summary notes (12): functors and adapters](/img/6d/a3a9cde2c8792579af7505c2226914.jpg)
[STL source code analysis] summary notes (12): functors and adapters
![[analysis of STL source code] summary notes (3): vector introduction](/img/70/faa40c273f6b3a6b124fb870058489.jpg)
[analysis of STL source code] summary notes (3): vector introduction
![P5431 [template] multiplicative inverse 2](/img/63/1cb95a55c9ce9b92d6d55381d0215b.jpg)
P5431 [template] multiplicative inverse 2

Seata的几种事务模式

Crmeb/v4.4 Standard Version open version mall source code applet official account h5+app mall source code
随机推荐
【CF#223 (Div. 2)】A. Sereja and Dima
Sqlzoo question brushing record-3
Compound RateModel合約解析
[analysis of STL source code] summary note (4): behind the scenes hero allocator
Senior openstacker - Bloomberg, vexxhost upgraded to the Gold member of openinfra Foundation
Education expert wangzhongze shared his experience for many years: family education is not a vassal
如果要存 IP 地址,用什么数据类型比较好?99%人都会答错!
The gap between the parent box and the child box
Analyse du contrat du modèle de taux composé
Compound ratemodel contract analysis
Pointer to a two-dimensional array
10 advanced concepts that must be understood in learning SQL
Find the longest common substring of N arrays (strings)
I/o multiplexing - select/poll/epoll
Notes on learning Es5 and ES6
mybaits-puls 在xml文件中写sql语句 会报错 Invalid bound statement (not found):
Sdl-3 YUV playback
Ffmpe a small demo to understand 80% of common APIs
Error occurred in pycharm DeprecatedEnv: Env FrozenLake-v0 not found (valid versions include [‘FrozenLake-v1‘])
【CF#654 (Div. 2)】A. Magical Sticks