Dialog.h
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class QStandardItemModel;
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = nullptr);
~Dialog();
private slots:
void on_one_clicked();
void on_two_clicked();
private:
Ui::Dialog *ui;
QStandardItemModel* model1;
QStandardItemModel* model2;
};
#endif // DIALOG_H
Dialog.cpp
#include "Dialog.h"
#include "ui_Dialog.h"
#include <QStandardItemModel>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
model1 = new QStandardItemModel;
model2 = new QStandardItemModel;
model1->setHorizontalHeaderLabels(QStringList()<<QStringLiteral("序号a") << QStringLiteral("名称a")); //设置列头