On Thu, Apr 18, 2013 at 6:43 PM, M. Bashir Al-Noimi <[email protected]>wrote:
> 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.
>
>
>
> 1. void MainWindow::on_comboBox_find_currentIndexChanged(int index)
> 2. {
> 3. if (p_db.isOpen()) {
> 4. //! \bug doesn't select the row although the index is
> correct!
> 5. if (p_tableModel->selectRow(index)) {
> 6. qDebug() << index;
> 7. }
> 8. }
> 9. }
>
> Voila I fixed it by:
1. void MainWindow::on_comboBox_find_currentIndexChanged(int index)
2. {
3. if (p_db.isOpen()) {
4. if (p_tableModel->selectRow(index)) {
5. ui->tableView_table->setCurrentIndex(p_tableModel->index(
index, 0));
6. qDebug() << index;
7. }
8. }
9. }
--
Best Regards
Muhammad Bashir Al-Noimi
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest