Dear All
How do set the focus for particular item in listview ,suppose if i have 100 items, and scroll bar also enabled..
Thanks
Yuvaraj R
Dear All
How do set the focus for particular item in listview ,suppose if i have 100 items, and scroll bar also enabled..
Thanks
Yuvaraj R
use scrollTo ( const QModelIndex & index, ScrollHint hint = EnsureVisible )
This will only scroll to make sure that item is visible.
But to set focus or select item. Need to call select.
Play withQt Code:
To copy to clipboard, switch view to plain text modeto achive your desired focus/selection effect on the item.Qt Code:
To copy to clipboard, switch view to plain text mode
Sorry for asking again
ui->listView->scrollTo(0,ScrollHint hint = EnsureVisible );
it is giving error like un declared scrollHint, ok,
How do i declare it... it is method of QAbstractitemView class..
please help me
Thanks
Yuvaraj R
You don't need to use ScrollHint hint = EnsureVisible, it is a default parameter.
This is enough:
Qt Code:
ui->listView->scrollTo(yourRowNumber);To copy to clipboard, switch view to plain text mode
Thanks Yogesh
same thing i want to scroll.. if my item is in lasr position,as per u , we set focused the item, but we don't we where it is ?
So i want to scroll it
vieraci
No it is giving error, if i pass only row value.
Thanks
Yuvaraj R
Thanks vieraci & Yogesh
It is working ,i did stupid mistake previouisly
Thanks
Yuvaraj R
Try this then:
Qt Code:
ui->listView->scrollTo(yourRowNumber, 0);To copy to clipboard, switch view to plain text mode
You may need to create an index for your row/column. Look at QAbstractItemModel::createIndex
And Yes, Yogesh is correct. You also need to select it as well.
Last edited by vieraci; 18th August 2009 at 07:13. Reason: updated contents
Bookmarks