When using setSelectionModel of TableView
Unsolved
General and Desktop
-
Using the frozen table view example, I am making a table view with fixed columns.
usrTableWidget::usrTableWidget(QWidget *parent) : m_pFrozenTable(new QTableView(this)) { Initialize(); this->connect( this->m_pFrozenTable->verticalScrollBar(), &QAbstractSlider::valueChanged, this->verticalScrollBar(), &QAbstractSlider::setValue ); this->connect( this->verticalScrollBar(), &QAbstractSlider::valueChanged, this->m_pFrozenTable->verticalScrollBar(), &QAbstractSlider::setValue ); } void usrTableWidget::InitFrozenTableview(usrTableModel* pModel) { //usrTableModel* pDataModel = qobject_cast<usrTableModel*>(this->model()); //pModel->SetRowData(pDataModel->GetInputData()); m_pFrozenTable->resizeColumnsToContents(); m_pFrozenTable->verticalHeader()->setDefaultSectionSize(m_Size.height()); m_pFrozenTable->setModel(pModel); m_pFrozenTable->setFocusPolicy(Qt::NoFocus); m_pFrozenTable->verticalHeader()->hide(); m_pFrozenTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); viewport()->stackUnder(m_pFrozenTable); m_pFrozenTable->setStyleSheet("QTableView { border: none;" "background-color: #8EDE21;" "selection-background-color: #999}"); //for demo purposes m_pFrozenTable->setSelectionModel(this->selectionModel()); for (int col = 1; col < pModel->columnCount(); ++col) m_pFrozenTable->setColumnHidden(col, true); m_pFrozenTable->setColumnWidth(0, columnWidth(0)); m_pFrozenTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_pFrozenTable->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_pFrozenTable->show(); UpdateFrozenPosition(); setHorizontalScrollMode(ScrollPerPixel); setVerticalScrollMode(ScrollPerPixel); m_pFrozenTable->setVerticalScrollMode(ScrollPerPixel); this->show(); }
m_pFrozenTable->setSelectionModel(this->selectionModel());
If you do not declare it, no data is displayed in the table view.The initial screen of the table view should contain only data in the heat-fixed table. So in this->selectionModel() I get an error because Model doesn't exist.
I want to show only the heat setting data on the initial screen.
Is there no way?