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
Printable View
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 with to achive your desired focus/selection effect on the item.Code:
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:
Code:
ui->listView->scrollTo(yourRowNumber);
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:
Code:
ui->listView->scrollTo(yourRowNumber, 0);
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.