2 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class MyItem : public QTableItem
{
public:
MyItem(QTable *table,EditType et,const QString& text)
: QTableItem(table,et,text)
{
m_crBkg = Qt::white;
m_crTxt = Qt::black;
m_HorzAlign = Qt::AlignRight;
m_VertAlign = Qt::AlignVCenter;
}
void paint(QPainter* p,const QColorGroup& cg,const QRect& cr,bool selected)
{
int w = cr.width();
int h = cr.height();
if (selected && colSpan() == 1 )
{
p->fillRect( 0 , 0 , w , h , cg.brush( QColorGroup::Highlight ) );
p->setPen( cg.highlightedText() );
}
else
{
p->fillRect( 0 , 0 , w , h , m_crBkg );
p->setPen( m_crTxt );
}
p->drawText( 2 , 0 , w - 4 , h , wordWrap() ? ( m_HorzAlign|m_VertAlign |
WordBreak) : m_HorzAlign|m_VertAlign , text() );
}
QColor m_crBkg;
QColor m_crTxt;
Qt::AlignmentFlags m_HorzAlign;
Qt::AlignmentFlags m_VertAlign;
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package MyItem;
use QTableItem; # nur geraten
use base qw/QTableItem/;
sub new
{
my ($parent, @args) = @_;
my $class = ref($parent) || $parent;
my $self = $class->SUPER::new(@args);
if(defined $self)
{
$self->{-crbkg} = Qt::white;
$self->{-crtxt} = Qt::black;
$self->{-horzalign} = Qt::AlignRight;
$self->{-vertalign} = Qt::AlignVCenter;
}
return $self;
}
sub paint(QPainter* p,const QColorGroup& cg,const QRect& cr,bool selected)
{
my ($self, $p, $cg, $cr, $selected) = @_
my $w = $cr->width();
my $h = $cr->height();
if($selected && $self->colSpan() == 1)
{
$p->fillRect( 0 , 0 , $w , $h , $cg->brush( QColorGroup::Highlight ) );
$p->setPen( $cg->highlightedText() );
}
else
{
$p->fillRect( 0 , 0 , $w , $h , $self->{-crbkg} );
$p->setPen( $self->{-crtxt} );
}
$p->drawText( 2 , 0 , $w - 4 , $h , $self->wordWrap() ? ( $self->{-horzalign}|$self->{-vertalign} |
WordBreak ) : ( $self->{-horzalign} | $self->{-vertalign} ) , $self->text() );
}
1;
2 Einträge, 1 Seite |