[Qt-interest] How to get the icon by default right side of listview
Andre Somers
andre at familiesomers.nl
Tue Mar 16 08:22:04 CET 2010
Ramesh wrote:
> Thanks Andre,
>
> no, I don’t want to use table view..
> in paint event of listview I can draw icon at my own position...
>
> just I asked is there any inbuilt support in Qt listview to draw icon at
> right side..
> because by default the icon are coming at left side..
>
> I tried one thig at paint event of listview before calling the base class
> paint
>
> "option.QStyleOptionViewItem(QStyleOptionViewItem::Right);"
>
>
> Its not working,, it says illegal type..
>
> Thanks..
>
OK, fine. Don't use a table view and do it the hard way instead.
Whatever suits you. :-)
Qt can, AFAIK, put the icon on the right, but I think it will normally
only do that if you are in RightToLeft layout mode. You could try to put
just your list view in that layout mode, but I would not be suprised if
your texts appear inverted too or other similar weird things happen. I
did not try it myself, so YMMV.
You could also try the route you are at now. However, you have to do it
slightly different than you are doing now. You don't set the position in
the constructor. Use the copy constructor to create a new style option
object, and then just set the decorationPosition to Right. Then pass
that new styleoption to the base class implementation. That should work.
Again, I did not try this myself.
André
>
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com
> [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Andre Somers
> Sent: Tuesday, March 16, 2010 12:20 PM
> To: Qt-interest
> Subject: Re: [Qt-interest] How to get the icon by default right side of
> listview
>
> Ramesh wrote:
>
>> Hi..
>>
>>
>>
>> I want listview to have an icon at right side and text at left side,
>> by default the icon is coming at left side and text will come after
>> the icon.
>>
>>
>>
>> How can I disply icon at right side of the listview and text at left
>> side..
>>
>>
>>
>> Any help on this?
>>
>>
>>
>>
> One option could be to use a table view instead, and just put your icon
> in a column of it's own on the right side of the text column.
>
> André
>
More information about the Qt-interest-old
mailing list