Qt-interest Archive, February 2007
subclassing QListView (to use QListViewItem subclass)
Message 1 in thread
Hi,
I want to have custom highlighting behaviour in my QListView. From
previous postings I understand that I have to subclass QListViewItem to
do so.
But now, I don't want to create the items myself, I want to make use of
QListView's model/view implementation as much as possible.
What QListView methods do I have to subclass in order to use
'QListViewItemSubclass' in the model/view process, and how?
Thanks for help,
Manu.
ps: I'm using Qt 4.2.0
--
[ signature omitted ]
Message 2 in thread
On 20.02.07 00:18:18, Manuela Hutter wrote:
> I want to have custom highlighting behaviour in my QListView. From
> previous postings I understand that I have to subclass QListViewItem to
> do so.
> But now, I don't want to create the items myself, I want to make use of
> QListView's model/view implementation as much as possible.
> What QListView methods do I have to subclass in order to use
> 'QListViewItemSubclass' in the model/view process, and how?
Unless you confused QListView and QListWidget what you want to do is not
the proper way to go. If you want to change how listview items are drawn
use your own item delegate and use a stock QListView. QListViewItem is
an implementation detail of QListView which you cannot depend on and
which you shouldn't care about.
If you're talking about QListWidget and QListWidgetItem: You're creating
the items yourself anyway, so I don't see why you'd want to avoid that.
Andreas
--
[ signature omitted ]
Message 3 in thread
oh, I got confused because apparently I was looking at Qt 3.3 examples.
delegates is what I need :-)
thanks for help, Andreas!
cheers,
Manu.
Andreas Pakulat wrote:
> On 20.02.07 00:18:18, Manuela Hutter wrote:
>> I want to have custom highlighting behaviour in my QListView. From
>> previous postings I understand that I have to subclass QListViewItem to
>> do so.
>> But now, I don't want to create the items myself, I want to make use of
>> QListView's model/view implementation as much as possible.
>> What QListView methods do I have to subclass in order to use
>> 'QListViewItemSubclass' in the model/view process, and how?
>
> Unless you confused QListView and QListWidget what you want to do is not
> the proper way to go. If you want to change how listview items are drawn
> use your own item delegate and use a stock QListView. QListViewItem is
> an implementation detail of QListView which you cannot depend on and
> which you shouldn't care about.
>
> If you're talking about QListWidget and QListWidgetItem: You're creating
> the items yourself anyway, so I don't see why you'd want to avoid that.
>
> Andreas
>
--
[ signature omitted ]