This small, self-contained example demonstrates that it does work:
Qt Code:
  1. #include <QtGui>
  2. #include <QDebug>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication app(argc, argv);
  7.  
  8. QStandardItemModel model(4, 4);
  9. for (int row = 0; row < 4; ++row) {
  10. for (int column = 0; column < 4; ++column) {
  11. QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
  12. model.setItem(row, column, item);
  13. }
  14. }
  15.  
  16. v.setModel(&model);
  17. v.setSelectionMode(QAbstractItemView::SingleSelection);
  18. v.setSelectionBehavior(QAbstractItemView::SelectRows);
  19. v.selectRow(0);
  20. v.show();
  21.  
  22. return app.exec();
  23. }
To copy to clipboard, switch view to plain text mode 

If you select row 1 and there is only one row in the table, row 0, then of course nothing is selected. We are not privy to the data your model is producing or any of the other things your code might be doing to the model or view, so we cannot tell you how to fix your code.

The program is written on way that if no row is selected the program crushes. ... Any suggestions?
This is the problem. Fix the program so that if there is no selected row in the table the user cannot trigger the event that would cause the program to "crush". Or, if you cannot stop the user triggering such events, make the offending code check for a selection and do nothing if one is not found (this is good defensive programming anyway). The alternative is to find everywhere a selection could be lost, for example deleting a row or resetting the model, and making sure you select something.