void MainWindow::SetupDetailWidget()
{
// Set up the ForecastDetail (database) table Model //
DetailModel->setTable ("ForecastDetail");
DetailModel->setSort (Detail_LineNmb_Col, Qt::AscendingOrder);
DetailModel->setHeaderData(Detail_itemId_Col, Qt::Horizontal, "Item");
DetailModel->setHeaderData(Detail_Qua_Col, Qt::Horizontal, "Qua");
// Set up the ForecastDetail (database) table View //
ui.tvForecastDetails->setModel(DetailModel);
ui.tvForecastDetails->setColumnHidden(Detail_Agency_Col, true);
ui.tvForecastDetails->setColumnHidden(Detail_LineNmb_Col, true);
ui.tvForecastDetails->setColumnWidth(Detail_itemId_Col, 70);
ui.tvForecastDetails->setColumnWidth(Detail_Qua_Col, 50);
const QModelIndex index
= ui.
tvForecastDetails->model
()->index
(0, Detail_Qua_Col
);
ui.tvForecastDetails->model()->setData(index, Qt::AlignCenter, Qt::TextAlignmentRole);
}
void MainWindow::SetupDetailWidget()
{
// Set up the ForecastDetail (database) table Model //
DetailModel = new QSqlRelationalTableModel(this);
DetailModel->setTable ("ForecastDetail");
DetailModel->setSort (Detail_LineNmb_Col, Qt::AscendingOrder);
DetailModel->setHeaderData(Detail_itemId_Col, Qt::Horizontal, "Item");
DetailModel->setHeaderData(Detail_Qua_Col, Qt::Horizontal, "Qua");
// Set up the ForecastDetail (database) table View //
ui.tvForecastDetails->setModel(DetailModel);
ui.tvForecastDetails->setColumnHidden(Detail_Agency_Col, true);
ui.tvForecastDetails->setColumnHidden(Detail_LineNmb_Col, true);
ui.tvForecastDetails->setSelectionMode (QAbstractItemView::SingleSelection);
ui.tvForecastDetails->setSelectionBehavior(QAbstractItemView::SelectRows);
ui.tvForecastDetails->setEditTriggers (QAbstractItemView::AllEditTriggers);
ui.tvForecastDetails->setColumnWidth(Detail_itemId_Col, 70);
ui.tvForecastDetails->setColumnWidth(Detail_Qua_Col, 50);
const QModelIndex index = ui.tvForecastDetails->model()->index(0, Detail_Qua_Col);
ui.tvForecastDetails->model()->setData(index, Qt::AlignCenter, Qt::TextAlignmentRole);
}
To copy to clipboard, switch view to plain text mode
Bookmarks