Customize Qtableview , Qsqlquerymodel ..etc
i use Qsqlquerymodel with sqlite3 DBMS
to retrieve data from database i use two Qtableview widgets
i want the user to be able to work like so:
the user uses only keyboard(no mouse )
when the data grabed from database and showed in the Qtableview via Qsqlquerymodel the first row in the table must be selected by default
the user uses arrow keys ( key_Down and Key_Up) to move between rows with "arrow.png" icon shown in verticalheader of Qtableview
when the user clics Entrer_Key, the row selected will be appened in the second Qtableview
plz help me , i have read model/view many times , and i figured out what really mean , but i still have a porbleme with customizing mytable view to work with
Qkeymouse events, currentrowchanged signal
no body can help me ?
Hi and welcome to devnet,
Please allow at least 24 hours before bumping your own thread, not all people here live in the same timezone as you or maybe even can help you.
Have a look at "activated":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#activated and "QItemSelectionModel":http://qt-project.org/doc/qt-4.8/qitemselectionmodel.html
You don't need to modify your QTableView if you are just going to react on the activated signal. You can do all the handling in the widget that will contain your two views.
for the first probleme
"when the data grabed from database and showed in the Qtableview via Qsqlquerymodel the first row in the
table must be selected by default"
i have used this code , and it works
for the second problem
"the user uses arrow keys ( key_Down and Key_Up) to move between rows "
i have use this and is work perfectly
but i have still a probleme her
with “arrow.png” icon shown in verticalheader of Qtableview"
i start using roles like displayrole ... etc her what i think
@ QVariant headerData(int section, Qt::Orientation orientation, int role) const
if(orientation == Qt::vertical)
if (the row is selected )
IIRC, using the DecorationRole should work, but why the icon ?
[quote author="SGaist" date="1374351243"]IIRC, using the DecorationRole should work, but why the icon ?[/quote]
how i can use decorationRole when the is selected ??