guidupas
17th April 2014, 20:23
Hello everyone!
I need to link a button click signal to add a row in my QStandardItemModel and I am trying to do this way, but It's not going OK.
void MainWindow::on_pushButtonNovoInvestimento_clicked( )
{
QPushButton *pushButtonAdicionarLancamentoInvestimento = new QPushButton;
pushButtonAdicionarLancamentoInvestimento->setText("Adicionar lançamento");
QTableView *tableViewLancamentosInvestimento = new QTableView;
QStandardItemModel *modeloLancamentosInvestimento = new QStandardItemModel(0, 2, this);
modeloLancamentosInvestimento->setHeaderData(0, Qt::Horizontal, "Valor");
modeloLancamentosInvestimento->setHeaderData(1,Qt::Horizontal, "Ações");
tableViewLancamentosInvestimento->setModel(modeloLancamentosInvestimento);
QSignalMapper *mapper = new QSignalMapper;
connect(pushButtonAdicionarLancamentoInvestimento, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(pushButtonAdicionarLancamentoInvestimen to, modeloLancamentosInvestimento);
connect(mapper, SIGNAL(mapped(QObject*)), this, SLOT(on_pushButtonAdicionarLancamentoInvestimento_ clicked(QObject*)));
}
void MainWindow::on_pushButtonAdicionarLancamentoInvest imento_clicked(QObject *modeloLancamentosInvestimento)
{
QStandardItemModel *modelo = modeloLancamentosInvestimento;
}
How can I do that?
Thanks a lot
I need to link a button click signal to add a row in my QStandardItemModel and I am trying to do this way, but It's not going OK.
void MainWindow::on_pushButtonNovoInvestimento_clicked( )
{
QPushButton *pushButtonAdicionarLancamentoInvestimento = new QPushButton;
pushButtonAdicionarLancamentoInvestimento->setText("Adicionar lançamento");
QTableView *tableViewLancamentosInvestimento = new QTableView;
QStandardItemModel *modeloLancamentosInvestimento = new QStandardItemModel(0, 2, this);
modeloLancamentosInvestimento->setHeaderData(0, Qt::Horizontal, "Valor");
modeloLancamentosInvestimento->setHeaderData(1,Qt::Horizontal, "Ações");
tableViewLancamentosInvestimento->setModel(modeloLancamentosInvestimento);
QSignalMapper *mapper = new QSignalMapper;
connect(pushButtonAdicionarLancamentoInvestimento, SIGNAL(clicked()), mapper, SLOT(map()));
mapper->setMapping(pushButtonAdicionarLancamentoInvestimen to, modeloLancamentosInvestimento);
connect(mapper, SIGNAL(mapped(QObject*)), this, SLOT(on_pushButtonAdicionarLancamentoInvestimento_ clicked(QObject*)));
}
void MainWindow::on_pushButtonAdicionarLancamentoInvest imento_clicked(QObject *modeloLancamentosInvestimento)
{
QStandardItemModel *modelo = modeloLancamentosInvestimento;
}
How can I do that?
Thanks a lot