71 lines
1.5 KiB
C++
71 lines
1.5 KiB
C++
#ifndef DEVPROPPAGE_H
|
|
#define DEVPROPPAGE_H
|
|
|
|
#include <QWidget>
|
|
#include <QPushButton>
|
|
#include <QTableView>
|
|
|
|
namespace Ui {
|
|
class DevPropPage;
|
|
}
|
|
|
|
class DevPropPage : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit DevPropPage(QWidget *parent = nullptr);
|
|
~DevPropPage();
|
|
|
|
|
|
void InitializeUI();
|
|
private slots:
|
|
void onTableViewDoubleClicked(const QModelIndex &index);
|
|
|
|
void onButtonClicked();
|
|
|
|
void adjustColumnWidths();
|
|
|
|
private:
|
|
Ui::DevPropPage *ui;
|
|
QTableView* tableView;
|
|
QPushButton* button;
|
|
};
|
|
|
|
class SimpleTableModel : public QAbstractTableModel {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
SimpleTableModel(QObject *parent = nullptr)
|
|
: QAbstractTableModel(parent) {
|
|
// 初始化数据(示例数据)
|
|
data_.resize(10); // 10行示例数据
|
|
for (int row = 0; row < 10; ++row) {
|
|
data_[row].resize(6, QString("Row %1, Col %2").arg(row).arg(row % 6));
|
|
}
|
|
}
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override {
|
|
Q_UNUSED(parent);
|
|
return data_.size();
|
|
}
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override {
|
|
Q_UNUSED(parent);
|
|
return 6; // 固定6列
|
|
}
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override {
|
|
if (!index.isValid() || role != Qt::DisplayRole)
|
|
return QVariant();
|
|
|
|
return data_[index.row()][index.column()];
|
|
}
|
|
|
|
private:
|
|
QVector<QVector<QString>> data_;
|
|
};
|
|
|
|
|
|
#endif // DEVPROPPAGE_H
|