Here is some code, I've cut and pasted so if I left out something interesting, please let me know. Thanks in advance for your kind assistance.
This is adding data rows to the model:
	
	- {	 
-        int the_level = outline->GetLevel(); 
-   
-        XiObjectListIter<XiRwOutputColumn> iter( outline->GetColumnIter() ); 
-        for (iter.Head(); iter.Valid(); iter.Next())  
-           iter.Data()->SetColumnText( iter.Data()->Evaluate() ); 
-   
-        rpt_item_data.setValue<XiRwOutputLine>( outline);  
-        row->setData( rpt_item_data, Qt::DisplayRole );  
-        [- B ]QSize-  size  =-  row -- >sizeHint ()- ; 
 
-        size.setWidth( 1500 ); 
-        row->setSizeHint( size );[/B] 
-        row->setFlags( Qt::NoItemFlags ); 
-        while (the_level <= indentations.last() && indentations.last() != 0 && (!outline->IsPreviewHdr().isEmpty() || outline->IsPreviewFtr() ) && rptItems.count() > 0) { 
-             rptItems.pop_back();  //line that is the current header 
-             rptItems.pop_back();  //that line's parent 
-             indentations.pop_back(); 
-        } 
-   
-        if ( !outline->IsPreviewHdr().isEmpty() ) 
-        { 
-             //append the header line, and then set me as the new parent 
-             rptItems.last()->appendRow( row ); 
-             row->setData( outline->IsPreviewHdr(), Qt::UserRole+1 ); 
-             indentations << the_level;             
-             if (rptItems.last()->rowCount() > 0) {  //parent->rowCount() > 0 
-                 rptItems << rptItems.last()->child(rptItems.last()->rowCount()-1); //parent = parent->child( parent->rowCount()-1 ); 
-                 rptItems << rptItems.last(); 
-             }  
-        } 
-        else            
-         rptItems.last()->appendRow( row ); 
-   
-        //after append: 
-        int rpt_cnt = rptItems.count(); 
-        int child_cnt = rptItems.last()->rowCount();        
-     } 
        {	
       QStandardItem* row = new QStandardItem();
       int the_level = outline->GetLevel();
     
       XiObjectListIter<XiRwOutputColumn> iter( outline->GetColumnIter() );
       for (iter.Head(); iter.Valid(); iter.Next()) 
          iter.Data()->SetColumnText( iter.Data()->Evaluate() );
       QVariant rpt_item_data;
       rpt_item_data.setValue<XiRwOutputLine>( outline); 
       row->setData( rpt_item_data, Qt::DisplayRole ); 
       [B]QSize size = row->sizeHint();
       size.setWidth( 1500 );
       row->setSizeHint( size );[/B]
       row->setFlags( Qt::NoItemFlags );
       while (the_level <= indentations.last() && indentations.last() != 0 && (!outline->IsPreviewHdr().isEmpty() || outline->IsPreviewFtr() ) && rptItems.count() > 0) {
            rptItems.pop_back();  //line that is the current header
            rptItems.pop_back();  //that line's parent
            indentations.pop_back();
       }
       
       if ( !outline->IsPreviewHdr().isEmpty() )
       {
            //append the header line, and then set me as the new parent
            rptItems.last()->appendRow( row );
            row->setData( outline->IsPreviewHdr(), Qt::UserRole+1 );
            indentations << the_level;            
            if (rptItems.last()->rowCount() > 0) {  //parent->rowCount() > 0
                rptItems << rptItems.last()->child(rptItems.last()->rowCount()-1); //parent = parent->child( parent->rowCount()-1 );
                rptItems << rptItems.last();
            } 
       }
       else           
        rptItems.last()->appendRow( row );
       //after append:
       int rpt_cnt = rptItems.count();
       int child_cnt = rptItems.last()->rowCount();       
    }
To copy to clipboard, switch view to plain text mode 
  
This is the size hint in the delegate:
	
	- if (qVariantCanConvert<XiRwOutputLine>(index.model()->data(index, Qt::DisplayRole )))  
-      { 
-          XiRwOutputLine outline = qVariantValue<XiRwOutputLine>(index.model()->data( index, Qt::EditRole ));  
-   
-          QSize-  row_height  =-  QStyledItemDelegate ::sizeHint(- option, index )- ; 
 
-          row_height.setHeight( outline->GetFHeight() ); 
-          [B]row_height.setWidth( 1500 );[/B] 
-          return row_height;          
-      } 
-     else{ 
-        QSize-  row_height  =-  QStyledItemDelegate ::sizeHint(- option, index )- ; 
 
-        row_height.setHeight( row_height.height() ); 
-       [B] row_height.setWidth( 1500 );[/B] 
-        return row_height;  
-     } 
        if (qVariantCanConvert<XiRwOutputLine>(index.model()->data(index, Qt::DisplayRole ))) 
     {
         XiRwOutputLine outline = qVariantValue<XiRwOutputLine>(index.model()->data( index, Qt::EditRole )); 
        
         QSize row_height = QStyledItemDelegate::sizeHint(option, index);
         row_height.setHeight( outline->GetFHeight() );
         [B]row_height.setWidth( 1500 );[/B]
         return row_height;         
     }
    else{
       QSize row_height = QStyledItemDelegate::sizeHint(option, index);
       row_height.setHeight( row_height.height() );
      [B] row_height.setWidth( 1500 );[/B]
       return row_height; 
    }
To copy to clipboard, switch view to plain text mode 
  This is the paint function:
	
	- QRect-  paint_rect  =-  option. rect- ; 
 
-          XiRwOutputLine outline = qVariantValue<XiRwOutputLine>(index.model()->data( index, Qt::EditRole )); 
-          [B]paint_rect.setWidth( outline->GetWidth() );[/B] 
-          painter->fillRect(paint_rect, qVariantValue<QBrush>(index.model()->data( index, Qt::BackgroundRole ))); 
-   
-          QPen-  orig_pen  =-  painter -- >pen ()- ;  
 
-          QFont-  orig_font  =-  painter -- >font ()- ; 
 
-         //set line font,  
-          QFont-  qfont  =-  outline -- >GetQFont ()- ; 
 
-          QColor-  qcolor  =-  outline -- >GetColor ()- ; 
 
-         //iterate through columns and create a print line for painting 
-          XiObjectListIter<XiRwOutputColumn> iter( outline->GetColumnIter() ); 
-            for (iter.Head(); iter.Valid(); iter.Next())  
-            {           
-              painter->setFont( iter.Data()->GetColumnFont() );              
-              if( iter.Data()->GetColumnColor().isValid() ) 
-                painter->setPen( iter.Data()->GetColumnColor() ); 
-              else 
-                painter->setPen( qcolor );             
-   
-              r.setWidth( iter.Data()->GetWidth() ); 
-              QString-  col_text ( (char*)- iter. Data()-- >GetColumnText ())- ;  
 
-              if( col_text.contains( "<!DOCTYPE html" ) ) 
-              { 
-                  q_txt.setHtml( col_text ); 
-                  q_txt.setPageSize( r.size()); 
-                  painter->translate(r.x(),r.y()); 
-                  q_txt.documentLayout()->draw(painter, context); 
-                  painter->restore(); 
-              } 
-              else 
-              {         
-                  switch (iter.Data()->GetJustification()) {	                
- 			             case XiRwOutputColumn::Right: 
- 				             painter->drawText(r,Qt::AlignRight,col_text); 
- 				             break; 
- 			             case XiRwOutputColumn::Center: 
- 				             painter->drawText(r,Qt::AlignCenter,col_text); 
- 				             break; 
-                    case XiRwOutputColumn::Wrap: 
-                      painter->drawText(r,Qt::TextWordWrap,col_text); 
- 				             break;		 
-                    default:                  
-                      painter->drawText(r,col_text); 
-                  } 
-              } 
-              r.setLeft( r.right()+3);              
-           } 
-           painter->setFont( orig_font ); 
-           painter->setPen( orig_pen ) ;            
-          } 
-   
-         else 
-         { 
-         QStyledItemDelegate::paint(painter, option, index); 
-         } 
        QRect paint_rect = option.rect;
         XiRwOutputLine outline = qVariantValue<XiRwOutputLine>(index.model()->data( index, Qt::EditRole ));
         [B]paint_rect.setWidth( outline->GetWidth() );[/B]
         painter->fillRect(paint_rect, qVariantValue<QBrush>(index.model()->data( index, Qt::BackgroundRole )));
         
         QTextDocument q_txt;
         QPen orig_pen = painter->pen(); 
         QFont orig_font = painter->font();
        //set line font, 
         QFont qfont = outline->GetQFont();
         QColor qcolor = outline->GetColor();
         QRect r = option.rect;  
        //iterate through columns and create a print line for painting
         XiObjectListIter<XiRwOutputColumn> iter( outline->GetColumnIter() );
           for (iter.Head(); iter.Valid(); iter.Next()) 
           {          
             painter->setFont( iter.Data()->GetColumnFont() );             
             if( iter.Data()->GetColumnColor().isValid() )
               painter->setPen( iter.Data()->GetColumnColor() );
             else
               painter->setPen( qcolor );            
             r.setWidth( iter.Data()->GetWidth() );
             QString col_text( (char*)iter.Data()->GetColumnText()); 
             if( col_text.contains( "<!DOCTYPE html" ) )
             {
                 q_txt.setHtml( col_text );
                 QAbstractTextDocumentLayout::PaintContext context;
                 q_txt.setPageSize( r.size());
                 painter->translate(r.x(),r.y());
                 q_txt.documentLayout()->draw(painter, context);
                 painter->restore();
             }
             else
             {        
                 switch (iter.Data()->GetJustification()) {	               
			             case XiRwOutputColumn::Right:
				             painter->drawText(r,Qt::AlignRight,col_text);
				             break;
			             case XiRwOutputColumn::Center:
				             painter->drawText(r,Qt::AlignCenter,col_text);
				             break;
                   case XiRwOutputColumn::Wrap:
                     painter->drawText(r,Qt::TextWordWrap,col_text);
				             break;		
                   default:                 
                     painter->drawText(r,col_text);
                 }
             }
             r.setLeft( r.right()+3);             
          }
          painter->setFont( orig_font );
          painter->setPen( orig_pen ) ;           
         }
 
        else
        {
        QStyledItemDelegate::paint(painter, option, index);
        }
To copy to clipboard, switch view to plain text mode 
  this is the code for setting the model in the rpt_view TreeView:
	
	- if (realized)  
-   {	 
-     report->finished = FALSE; 
-     rpt_view->setItemDelegate( new RWPreviewDelegate( ));  
-     rpt_view->setModel( rpt_model ); 
-     [B]rpt_view->setColumnWidth( 0,1500 );[/B]  
-     if( report->finished ) 
- 		    report->UnRealize(); 
-   } 
        if (realized) 
  {	
    report->finished = FALSE;
    rpt_view->setItemDelegate( new RWPreviewDelegate( )); 
    rpt_view->setModel( rpt_model );
    [B]rpt_view->setColumnWidth( 0,1500 );[/B] 
    if( report->finished )
		    report->UnRealize();
  }
To copy to clipboard, switch view to plain text mode 
  
				
			
Bookmarks