Qt-interest Archive, April 2007
In DelegateItem Paint()
Message 1 in thread
Hello List
I m just reimplementing the paint() in a subclass of QItemDelegate. But
some things are not realy clear to me.
I receive the QStyleOptionViewItem to know where i am on the QListView.
I managed to do some basic drawing on each element using QRectF and
drawRect(). But How would i adjust the height of each row? so that fore
example the Editor (which is the default still) is respecting the new
height? Or would i have to keep the sizes of each item i draw so that
others are positioned accordingly?
Which brings me to another problem. The Target is a List of Items
(QListView). But the DataSource is a Sql Db. Therefore the Model i use
is a QSqlTableModel. Can i still use the QListView and the Delegate to
display different results of the Db in one List Item? Is the Index i
receive aware of the underlying Model?
I m a little confused. Maybe someone has some other material to read
about this than the offical docs? Especially on how to rewrite the Paint()?
Any Light for me in the dark ?
Thank you
Manuel
--
[ signature omitted ]
Message 2 in thread
Hello List,
can i add Widgets to a Delegate? I have done some drawing nowin, and
actualy dont want do catch the click event to see where the click
appeared. The Doc just talks about the Editor, which i actually dont
need, since its a read only view.
So, is it possible to add Widgets and dont have to catch click and hover
events manualy? For example a QPushButton? or even a layout?
Thanks
Manuel Schmidt schrieb:
> Hello List
> I m just reimplementing the paint() in a subclass of QItemDelegate.
> But some things are not realy clear to me.
> I receive the QStyleOptionViewItem to know where i am on the
> QListView. I managed to do some basic drawing on each element using
> QRectF and drawRect(). But How would i adjust the height of each row?
> so that fore example the Editor (which is the default still) is
> respecting the new height? Or would i have to keep the sizes of each
> item i draw so that others are positioned accordingly?
>
> Which brings me to another problem. The Target is a List of Items
> (QListView). But the DataSource is a Sql Db. Therefore the Model i use
> is a QSqlTableModel. Can i still use the QListView and the Delegate to
> display different results of the Db in one List Item? Is the Index i
> receive aware of the underlying Model?
>
> I m a little confused. Maybe someone has some other material to read
> about this than the offical docs? Especially on how to rewrite the
> Paint()?
>
> Any Light for me in the dark ?
>
> Thank you
>
> Manuel
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]
Message 3 in thread
I suppose you could, but I don't think that's the correct use of a delegate (or the model-view pattern). The delegate doesn't own any views. The view grants the delegate the right to paint and process events (via the event filter and the paint method). The delegate should interact with the view & its model via the view/model's public interfaces and the delegates public methods.
It sounds to me like you want a specialized view. In this case you might want to think about deriving QListView for the special case that you are describing.
One of the features of the view/delegate relationship is that the view can ask delegate to create an editor for an index in the view. I realize that you aren't choosing to use that feature, but that doesn't change the role of the delegate.
What kind of widgets are you talking about adding? Could clarify your use case?
-- Susan
----- Original Message ----
From: Manuel Schmidt <manuel@xxxxxxxxxxxxx>
To: qt-interest <qt-interest@xxxxxxxxxxxxx>
Sent: Wednesday, April 25, 2007 10:22:14 AM
Subject: Re: In DelegateItem Paint()
Hello List,
can i add Widgets to a Delegate? I have done some drawing nowin, and
actualy dont want do catch the click event to see where the click
appeared. The Doc just talks about the Editor, which i actually dont
need, since its a read only view.
So, is it possible to add Widgets and dont have to catch click and hover
events manualy? For example a QPushButton? or even a layout?
Thanks
Manuel Schmidt schrieb:
> Hello List
> I m just reimplementing the paint() in a subclass of QItemDelegate.
> But some things are not realy clear to me.
> I receive the QStyleOptionViewItem to know where i am on the
> QListView. I managed to do some basic drawing on each element using
> QRectF and drawRect(). But How would i adjust the height of each row?
> so that fore example the Editor (which is the default still) is
> respecting the new height? Or would i have to keep the sizes of each
> item i draw so that others are positioned accordingly?
>
> Which brings me to another problem. The Target is a List of Items
> (QListView). But the DataSource is a Sql Db. Therefore the Model i use
> is a QSqlTableModel. Can i still use the QListView and the Delegate to
> display different results of the Db in one List Item? Is the Index i
> receive aware of the underlying Model?
>
> I m a little confused. Maybe someone has some other material to read
> about this than the offical docs? Especially on how to rewrite the
> Paint()?
>
> Any Light for me in the dark ?
>
> Thank you
>
> Manuel
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]