PDA

View Full Version : QTreeView clicked signal coordinates



michalk
1st February 2011, 10:50
It is my first post in this forum so I would like to say hello to all Qt programmers.
Hello :)

Could anyone help me in following problem:
I would like to receive coordinates of QTreeView clicked signal.
I need them because action performed on item displayed in tree view will depend of where this item was clicked. clicked signal is called with QModelIndex argument and I couldn't find any coordinate related info.

Application is developed for Symbian devices.
Thank you in advance

kosasker
1st February 2011, 11:11
in your header write a slot like


void treeViewClickProgress();

after in your source code in mainwindows calling state


QObject::connect(treeview,SIGNAL(Clicked),this,SLO T(treeViewClickProgress()));


and at last write a void function like this;



void MainWindow::treeViewClickProgress()

{
int rowNum = ui->treeView->selectionModel()->currentIndex().row();
int colNum= ui->treeView->selectionModel()->currentIndex().column();
qDebug() << rowNum << colNum;
}


hope this help...
edit...
dont copy paste, thats pseudo code only..

michalk
1st February 2011, 11:52
Thank you for your anwser.

I was thinking about X and Y coordinates of point which user touched on screen, but separating one column into many columns maybe a right solution.
I have to check it...

wysota
1st February 2011, 13:21
Reimplement the QAbstractItemDelegate::editorEvent() for your view's delegate (you'll have to provide one). There you can get all the coordinates you want. Signals and slots is a more high level mechanism which is not suited for what you want.