I wanted to create a QTableWidget and populate it with different values.

My code is:

 for i:= 1 to len(aL)
    aAdd( oGridItem0x0 , "" )
    t := QTableWidgetItem():new()
    t:setBackground( oBrushBackItem0x0 )
    t:setForeground( oBrushForeItem0x0 )
    t:setText( "cella "+str(i) )
    oGrid:setItem( i-1, 0, t )
 next

The result was that only the last cell has value... this happens
because when t is re:New()ed, the previous t is destroyed ... so
::setItem needs  treatment for detaching it when calling setItem....

So please apply this patch:

HB_FUNC( QT_QTABLEWIDGET_SETITEM )
{
    QGC_POINTER_QTableWidget * q;
    QGC_POINTER * p;

    HB_TRACE( HB_TR_DEBUG, ("Entering QTABLEWIDGET_SETITEM" ) );

  q = ( QGC_POINTER_QTableWidget * ) hb_parptrGC( hbqt_gcFuncs(), 1 );
  p = ( QGC_POINTER * ) hb_parptrGC( hbqt_gcFuncs(), 4 );

  if( p && p->ph && q && q->ph )
  {
     HB_TRACE( HB_TR_DEBUG, ( "QT_QTABLEWIDGET_SETITEM() Qt oject: %p
is attached to: %p", ( void * ) p->ph, ( void * ) q->ph ) );
     p->bNew = HB_FALSE;
     ( q->ph )->setItem( hb_parni( 2 ), hb_parni( 3 ), (
QTableWidgetItem * ) p->ph );
  }

}


Francesco

PS: why didn't you use my patch to have the "exceptional" functions
out of qth files ?
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to