Your code worked.

I have another problem. When I click on the pushbutton 'Add Task' will want to add a task list that is declared in taskModel.
I have this code but does not work ...

Qt Code:
  1. void MainWindow::on_addTarefa_clicked()
  2. {
  3. Task t1(ui->lineNameTask->text());
  4. // t1.setContext(ui->LineContext->text());
  5. // t1.setProject(ui->lineProject->text());
  6. TaskModel model(5);
  7. model.addTask(t1);
  8.  
  9. // TaskModel::taskList.push_back(t1);
  10. }
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. void TaskModel::addTask(const Task &task){
  2. beginInsertRows(QModelIndex(), rowCount(),rowCount());
  3. qDebug("hello");
  4. // taskList<< task;
  5. taskList.push_back(task);
  6. endInsertRows();
  7. }
To copy to clipboard, switch view to plain text mode