PDA

View Full Version : [QT3] QListView



incapacitant
29th January 2006, 12:16
Hello,

In QListViews one can define columns, say from left to right A, B and C; and of course lines say from top to bottom 1, 2, 3...

I try to modify (for instance) the content of cell B2.

For the time being, I could not invent better than to click with the mouse (left) on line 2. This puts A2 as selected. I then loop through the list to find which line has been selected.

Then I programmed function key F1 to edit A2, F2 to edit B2, F3 to edit C2 etc...

But I really would like to click on any cell and program a slot to handle it.

Is there a better way that I could investigate ?

jacek
29th January 2006, 13:58
You mean something like QListView::clicked( QListViewItem *, const QPoint&, int) signal?

incapacitant
29th January 2006, 14:16
Yes this should work. I am going to try. Thank you.

incapacitant
29th January 2006, 14:48
I have some trouble writing the SIGNAL for above.

connect( articles, SIGNAL( clicked( QListViewItem* ), const QPoint & pnt, int col ),
this, SLOT( itemSelected( QListViewItem* ) ) );
This says SIGNAL takes only one parameter, while here being passed 3.

connect( articles, SIGNAL( clicked( QListViewItem* ) ),
this, SLOT( itemSelected( QListViewItem* ), const QPoint & pnt, int col ) );
This says SLOT takes only one parameter, while here being passed 3.

How should the connect be coded ?

jacek
29th January 2006, 14:56
No parameter names are allowed in SIGNAL and SLOT macros, so it should be:
connect( articles, SIGNAL( clicked( QListViewItem *, const QPoint&, int ) ), this, SLOT( itemSelected( QListViewItem * ) ) );
If you don't need the third parameter (i.e. column), you can use different signal:
connect( articles, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( itemSelected( QListViewItem * ) ) );

incapacitant
29th January 2006, 15:31
:)
In the end I used rightButtonClicked with the same syntax as you said, and it WORKS !

Thank you very much for your help.