MainWindow::MainWindow()
{
    QSpreadsheetHeaderView *hv = new QSpreadsheetHeaderView(Qt::Horizontal, this);
    hv->setClickable(true);
    hv->setHighlightSections(true);
    TableModel *model = new TableModel(this);
    QTableView *tv = new QTableView(this);
    tv->setModel(model);
    tv->setHorizontalHeader(hv);

    setCentralWidget(tv);
}
示例#2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QSpreadsheetHeaderView *headView = new QSpreadsheetHeaderView(Qt::Horizontal, this);
    headView->setSectionsClickable(true);
    headView->setHighlightSections(true);
    TableModel *model = new TableModel(this);
    TableView *tableView = new TableView(this);

    tableView->setModel(model);
    tableView->setHorizontalHeader(headView);
    tableView->horizontalHeader()->setStretchLastSection(true);

    setCentralWidget(tableView);
}