[Qt-interest] error in moc file

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Mar 18 16:01:08 CET 2010


Ramesh wrote on Thursday, March 18, 2010 10:34 AM:

> I am not getting exactly what you are telling, what is the use of
> overriding " selectionchange " method?

I wrote you should overwrite the 'setSelection' method, NOT 'selectionChanged' method (and be careful with your spelling, there is a 'd' at the end - just in case...).

Anyway, I wasn't even aware that there is also a http://doc.trolltech.com/4.6/qabstractitemview.html#selectionChanged method, which is more convenient.

I understand you want to get a signal - say "signalSelectionChanged" - whenever the selection in a QListView changes (in whatever way). QListView itself does not provide such a signal (AFAIK, see http://doc.trolltech.com/4.6/qlistview.html#signals), so simply:

1. Inherit from QAbstractItemView (or directly from QListView), say "MyListView"

2. Overwrite selectionChanged (as you already did)

3. In your implementation, emit a signal "signalSelectionChanged"

4. Instantiate your custom "MyListView" instead of QListView and connect to "signalSelectionChanged" as needed.
 
> I have done like this,
> 1)inherit the listview
> 2)override the "selectionchange" slot

So what does your implementation in "selectionChanged" look like? Do you emit a custom signal, as suggested?

Again, this is 'selectionChanged'! Take care of your spelling, including Capitalisation! Or you might not actually overwrite any method. (And yes, I /do/ have my doubts that people write correct code if they do the same spelling errors in emails ;)

> if I do this I am not getting the control only..

I don't understand this - what "control"? What does "not getting only" mean? What is it exactly you want to "get"?


Cheers, Oliver
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list