[Interest] Setting current row in QSqlTableModel

Sviatoslav Feshchenko sviatoslav at outlook.com
Thu Apr 18 18:54:58 CEST 2013


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: mbnoimi at gmail.com
Date: Thu, 18 Apr 2013 18:43:02 +0200
To: interest at qt-project.org
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 Interest at qt-project.org http://lists.qt-project.org/mailman/listinfo/interest 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130418/1538f5d5/attachment.html>


More information about the Interest mailing list