PDA

View Full Version : Connect button and pass QListView current index



been_1990
23rd November 2009, 00:55
I want to connect a edit button to a editInfo() slot and pass the current selected index of a QListView as an argument. :D
I dont think theres a way to pass a QListView index trough the clicked() signal. So I have to create a signal thats get triggered by the button being clicked, and then sends a signal to editInfo() passing the list's current index???? Maybe.. ?

aamer4yu
23rd November 2009, 05:20
How about QAbstractItemView::clicked ( const QModelIndex & index ) [signal] ?

Also if your items are editable, the view might just provide an automatic editor. Why do u need extra handling of editing info ? Have a look at the delegates examples( under item views) in Qt Demos.

been_1990
23rd November 2009, 14:12
The ListView has the names of XML files shown on a directory, so I want to select the files name, click a "edit" button and send the currentIndex(wich is a XML file name, say, options.xml) to a function for editing.

been_1990
30th November 2009, 17:20
Ok, quite simple. Stupid me.

dialog.editAlarm(ui->alarmList->currentIndex().data(0).toString());
Where "dialog" is my Dialog class, and editAlarm() is a public slot from Dialog.