PDA

View Full Version : 2 QTableViews data



guidupas
30th April 2014, 21:26
Hello all!

I have a code that create 2 QTableViews dynamically when a QPushButton is clicked:



void MainWindow::on_pushButtonNovoInvestimento_clicked( )
{
QTableView *tableViewLancamentosInvestimento = new QTableView(boxInvestimento2);
QTableView *tableViewIndicadoresInvestimento = new QTableView(boxInvestimento2);

QStandardItemModel *modeloLancamentosInvestimento = new QStandardItemModel(0, 3, tableViewLancamentosInvestimento);
QStandardItemModel *modeloIndicadoresInvestimento = new QStandardItemModel(0, 2, tableViewIndicadoresInvestimento);

tableViewLancamentosInvestimento->setModel(modeloLancamentosInvestimento);
tableViewIndicadoresInvestimento->setModel(modeloIndicadoresInvestimento);

connect(modeloLancamentosInvestimento, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(alteraModeloLancamentoInvestimento(QModelInde x,QModelIndex)));
}


But I need that when data of the first model changes, some data of the second model changes too.

How can I do that once the 2 models are created dynamically?

I am trying to do something like the code above, but its not working:


void MainWindow::alteraModeloLancamentoInvestimento(QMo delIndex topLeft, QModelIndex bottomRight)
{
QStandardItemModel *modeloLancamentosInvestimento = qobject_cast<QStandardItemModel *>(sender());
}


How can I access the second model?