PDA

View Full Version : Can't I modify qlistview's item? can i modify only qlistwidget's item?



melody:p
2nd August 2012, 10:04
I want to modify listview's item.

so I add code this:



setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);


but anythings are not changed.
I double-click listview's item, but i can't edit item..

I show some example about editing tablewidget's item.

Can I edit only listWIDGET or tableWIDGET, NOT listVIEW, tableVIEW??

than why listview has <setEditTriggers>function??
I can't understand.....

PLEASE HELP ME!

amleto
2nd August 2012, 11:02
have you examined the model -view examples?

melody:p
3rd August 2012, 01:23
Thanks for your answer!

sorry..
Where is model-view example?
I examined only itemview example.
I can't find model-view example.
Is right you mean example of qt\4.8.2\exmaples?

I think editable itemview's exmaple is only listwidget not listview..
Isn't it??

ChrisW67
3rd August 2012, 02:37
The model underlying the view class needs to be editable or the view will not be able to edit it regardless of the edit triggers. The model needs to return Qt::ItemIsEditable amongst the flags() for the items the model allows editing for.

melody:p
3rd August 2012, 03:27
I FIND EDITABLE LISTVIEW EXMAPLE!
but, this example use QStringListModel.
so I change QStingListModel to QAbstractListModel that i reimplement.
than this exmaple is broken! changed to no-editable ...
why????:crying:

thankyou ChrisW67.
actually I can't fully understand you're answer.
but roughly understanding, i add code


Qt::ItemFlags GalleryModel::flags(const QModelIndex & index)
{
return Qt::ItemIsEditable;
}


GalleryModel is my QAbstractListModel...

isn't what you mean?
but still item's not changed..

when called flag function of model?
I can't understand :confused:

spirit
3rd August 2012, 06:24
This (http://qt-project.org/doc/qt-4.8/model-view-programming.html) should spill the light.

melody:p
3rd August 2012, 06:48
oh my god....
You were right!
I reimplement flags and setdata function. but It is not activate properly. so I ask a question you continues..
Because I think i do all action for listview's editable, I am very confused.
But I find I droped word 'const' in my flags function:eek:
And I got the all I wants.
THANK YOU! THANK YOU!

sprit Thanks for your interest.
Actually, i can't understand 'This should spill the light.'s mean..
It means you need more information?
I can't speak english, well. sorry.
IF we will meet next time, help me please! thank you:)