FYI, selectRow() retrieves the row from the database, similar to select() which retrieves all rows from the database (subject to optimizations, which may result in less than all rows actually being retrieved) The function you need is QAbstractItemView::setCurrentIndex documented here http://qt-project.org/doc/qt-5.0/qtwidgets/qabstractitemview.html#setCurrentIndex This function is inherited by QTableView. Hope this helps! Cheers.
From: [email protected] Date: Thu, 18 Apr 2013 18:43:02 +0200 To: [email protected] Subject: [Interest] Setting current row in QSqlTableModel Hi, Could you please guide me how can I set the current row in QSqlTableModel? PS I’ve QTableView and QComboBox both of them attached to same QSqlTableModel I want to set the current row in QTableView dependeing on selected index in QComboBox. I can get the selected index in QComboBox through currentIndexChanged(int index) slot but I don’t know to set the current in QSqlTableModel. void MainWindow::on_comboBox_find_currentIndexChanged(int index) { if (p_db.isOpen()) { //! \bug doesn't select the row although the index is correct! if (p_tableModel->selectRow(index)) { qDebug() << index; } } } -- Best Regards Muhammad Bashir Al-Noimi _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
