Hi,
in many QT methods, for example the data() method of QAbstractTableModel (and many others) I am creating objects on the stack and returning them, like this:

Qt Code:
  1. QVariant ActionListModel::data(const QModelIndex &index, int role) const {
  2. Action *a;
  3. int row_num,col_num;
  4. col_num=index.column();
  5. row_num=index.row();
  6. if (row_num>=actions->count()) return (QVariant());
  7. a=actions->value(row_num);
  8. if (a==0) {
  9. return(QVariant());
  10. }
  11. if (role==Qt::DecorationRole) {
  12. if (col_num==0) {
  13. cat_action_id_t act_code;
  14. act_code=a->get_action_code();
  15. switch(act_code) {
  16. case CAT_ACTION_UNDEFINED: {
  17. break;
  18. }
  19. case CAT_ACTION_COMMENT : {
  20. QPixmap icon("/home/action_type_icons/comment.png");
  21. return(icon);
  22. break;
  23. }
  24. case CAT_ACTION_NEW_DEPENDENCY: {
  25. QPixmap icon("/home/action_type_icons/new_dependency.png");
  26. return(icon);
  27. break;
  28. }
To copy to clipboard, switch view to plain text mode 

The "icon" variable is created on the stack and is destroyed after the method execution ends, but I am not getting segmentation faults in my app. The question is, how does it work ? Is QT copying all objects I am returning in the QT methods that I am overriding?

TIA.