mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 16:55:25 +08:00
qt 6.5.1 original
This commit is contained in:
33
examples/widgets/tutorials/modelview/5_edit/mymodel.h
Normal file
33
examples/widgets/tutorials/modelview/5_edit/mymodel.h
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef MYMODEL_H
|
||||
#define MYMODEL_H
|
||||
|
||||
//! [Quoting ModelView Tutorial]
|
||||
// mymodel.h
|
||||
#include <QAbstractTableModel>
|
||||
#include <QString>
|
||||
|
||||
const int COLS= 3;
|
||||
const int ROWS= 2;
|
||||
|
||||
|
||||
class MyModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyModel(QObject *parent = nullptr);
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
private:
|
||||
QString m_gridData[ROWS][COLS]; //holds text entered into QTableView
|
||||
signals:
|
||||
void editCompleted(const QString &);
|
||||
};
|
||||
//! [Quoting ModelView Tutorial]
|
||||
|
||||
#endif // MYMODEL_H
|
Reference in New Issue
Block a user