PDA

View Full Version : How can i select a row at startup



kosasker
1st February 2011, 12:28
i want to select a treeview row at startup



QModelIndex index= new QModelIndex(1,0,void ????, model);
ui->treeView->setRootIndex(index);


i dont know how can i do it... i just want to select a row at startup... please help!!!

Edit:

I cant understand model/view arch. logic... i read local help files, looked at samples too...

I can get index of the selected items, but i cant store them (in textfile or registry) Gone a be crazy...:(

Also i tried to give row and coloumn numbers manually, but i cant do it. if i can select it manually on start up, my problem will be solved... Please help...

Added after 36 minutes:

Yep...

Forget treeview... i solved this with using tableview... right widget for right work...thanks all..

BalaQT
1st February 2011, 13:07
hi,

I cant understand model/view arch. logic
http://doc.qt.nokia.com/latest/model-view-programming.html
pls go through this link. this is essential for qt programming.
hope it helps
Bala

wysota
1st February 2011, 14:04
You can't create model indexes by yourself. Only the model can create an index.


QModelIndex index = model->index(1, 0); // row = 1, column = 0, top-level item (invalid parent)
ui->treeView->setModel(model);
ui->treeView->selectionModel()->select(index);

kosasker
1st February 2011, 14:25
@wysota:Thank you bro

@balaQt: i always looking first my local help. thank you too..