qt - How to force QAbstractItemView recalculate items sizeHints -


i have qlistview , qtabwidget inside qsplitter. qlistview using custom model , custom delegates. in delegate reimplemented paint , sizehint methods. when resize view - height of elements doesn't recalculated. how can fix it? sample images: before resizingafter resizing

in google found possible emit layoutchanged model, want current view updated, because content of model doesn't change.

delegate code:

void chatitemdelegate::paint( qpainter *painter, const qstyleoptionviewitem& option, const qmodelindex& index ) const {     painter->save();      chatitem *item = static_cast< chatitem * >( index.internalpointer() );     qtextdocument doc;      doc.sethtml( item->htmltext() );     doc.settextwidth( option.rect.width() );      qrect clip( 0, 0, option.rect.width(), option.rect.height() );     painter->translate( option.rect.topleft() );      qcolor bgcolor = index.row() % 2 ? qcolor( 255, 0, 0, 40 ) : qcolor( 0, 255, 0, 40 );     painter->fillrect( clip, bgcolor );     doc.drawcontents( painter, clip );      qdebug() << "paint: " << option.rect.width() << " idx: " << index.row();      painter->restore(); }  qsize chatitemdelegate::sizehint( const qstyleoptionviewitem& option, const qmodelindex& index ) const {     chatitem *item = static_cast< chatitem * >( index.internalpointer() );     qtextdocument doc;      doc.sethtml( item->htmltext() );     doc.settextwidth( option.rect.width() );      qdebug() << "hint:  " << option.rect.width() << " idx: " << index.row();      return doc.size().tosize(); } 

similar question

this bit of guess, setting qlistview's resize mode help?

listview->setresizemode( qlistview::adjust ); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -