francesco perillo wrote:
>
> PS: why didn't you use my patch to have the "exceptional" functions
> out of qth files ?
>
Because we are not to deal with a whole new set of files which
may go unmanageable in the long run.
Also we agreed that this mechanism will be usedonly where we have
problem with the destruction mecanism.
> 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 );
> }
>
> }
>
Local aItems := {}
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 )
aadd( aItems, t )
next
// And destructor
for each aItm in aItems
qItm := NIL
next
This mechanism has an advantage.
You have all the control over items spread in different columns,
and can later deal with them if there is a need of changes, for example,
if you would like to let it be edited or changing the colors.
This is how it looks close to Clipper syntax.
-----
enjoy hbIDEing...
Pritpal Bedi
http://hbide.vouch.info/
--
View this message in context:
http://harbour-devel.1590103.n2.nabble.com/Patch-for-Pritpal-tp4977113p4977369.html
Sent from the harbour-devel mailing list archive at Nabble.com.
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour