Thanks for the reply, but I don't think the name(tablewidget) is an issue.
However, my problem solve. not sure what is the issue. but the following code works.
$D{tablewidget.In}
$D{detail.nextLine}
$S{
if($D{tablewidget.In} == "") {
THIS.fontColor=QColor('white')
setVariable("colourFlag","1");
}
else{
setVariable("colourFlag","0")
}
}
$S{if($D{tablewidget.InStatus}==2 && getVariable("colourFlag") == 0)
THIS.fontColor=QColor('green')
else if($D{tablewidget.InStatus}==3 && getVariable("colourFlag") == 0)
THIS.fontColor=QColor('red')
else if(getVariable("colourFlag") == 0)
THIS.fontColor=QColor('black')
}