0

I know how to bind the QSqlTableModel and QTableView to display all the data in the specific table in the databases. Here, it's my code.

QSqlTableModel model;
QTableView *view1 = createView(&model, QObject::tr("Table Model (View 1)"));
view1->setSelectionBehavior(QAbstractItemView::SelectRows);

If I need to jump the other form as I click the ith-row on the view, how do I assign the click event?

For example, If I click the 3rd rows, I will jump to the user form to show the 3rd user info.

Gapry
  • 253
  • 1
  • 7
  • 20
  • What do you mean by another form..? You mean some other widget.>? Can you add some code to show that.? – PRIME Jan 14 '16 at 13:54

1 Answers1

0

Obtain the QItemSelectionModel from by calling QTableView::selectionModel(). Connect to the signal QSelectionModel::selectionChanged(QItemSelection const&, QItemSelection const&). In your slot, you can examine the change of selection the determine what has been clicked on.

Brad
  • 486
  • 2
  • 8