Qt c++: items overlap in QStyledItemDelegate descendant (QListView contents) -


i have bit of problem writing prototype application. wrote sample item delegate, implemented sizehint , paint methods , seems paint ignores changes qrect variable used painting: items aligned left , overlap. sample code follows:

void blabdelegate::paint(qpainter *painter, const qstyleoptionviewitem &option, const qmodelindex &index) const {     qstyleditemdelegate::paint(painter,option,index);     painter->save();     qrect irect(option.rect);     irect.setheight(54); irect.setwidth(54);     qapplication::style()->drawitempixmap(painter,irect,0,amodel->get(index.data().tohash()["avatar"].tostring()).scaledtoheight(54));     irect = option.rect;     irect.setleft(64); irect.setbottom(option.rect.bottom()-20);     qtextdocument doc;     doc.sethtml(index.data().tohash()["text"].tostring());     doc.drawcontents(painter,irect);     painter->restore(); }  qsize blabdelegate::sizehint(const qstyleoptionviewitem &option, const qmodelindex &index) const {     qstyleoptionviewitem iopt = option;     iopt.rect.setheight(64);     return qsize(iopt.rect.width(),64); } 

now, qdebug() states irect has correct values (as expected) qtextdocument looks inserted under icon when should begin 64px offset left. there don't understand writing paint method? why above code not work? appreciate since cannot find right answer.

kind regards, artur

edit: have inserted changes saz suggested.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -