[Qt-interest] selection / focus issue with QTableView

Darrik Mazey darrik.lists at dmtprogramming.com
Sat Dec 20 17:19:34 CET 2008


Greetings (seasonal or otherwise), list!

I have a subclassed AbstractItemModel, a QTableView, and a QLineEdit 
connected in such a way that the user types a search query string in the 
QLineEdit and presses enter, the model does a search, and the table 
displays the results.  Pretty standard.  Everything functions as expected.

What I want to happen is that when the model populates, I want the table 
view to automatically get focus and select the first row, such that the 
user can easily use the arrow keys to navigate between rows.

I've connected the model's dataChanged() signal to a slot in my window. 
  In that slot I attempt to call selectRow(0) on the view and 
setFocus().  This does not work from that slot.  It works outside the 
slot, but when called from the slot connected to dataChanged(), it does 
not work.

Has anyone else experienced this?  Is there a better way to do this?  Is 
there a reason it shouldn't function when called from this slot?

Any help would be appreciated.

Cheers,
Darrik

-- 
Darrik Mazey
Developer
DMT Programming, LLC.
P.O. Box 91
Torrington, CT 06790
office: 330.983.9941
    fax: 330.983.9942
mobile: 330.808.2025
darrik at dmtprogramming.com

To obtain my public key, send an email to 
darrik at publickey.dmtprogramming.com.



More information about the Qt-interest-old mailing list