{
double angle;
for( n = 0; n < paintLines.count(); ++n )
{
k = paintLines[n];
temp = k.split( "," );
xs = temp[0].toInt( &ok );
ys = temp[1].toInt( &ok );
xe = temp[2].toInt( &ok );
ye = temp[3].toInt( &ok );
painter.drawLine( xs, ys, xe, ye );
}
for( n = 0; n < paintLabels.count(); ++n )
{
k = paintLabels[n];
temp = k.split( "," );
xs = temp[0].toInt( &ok );
ys = temp[1].toInt( &ok );
angle = temp[2].toDouble( &ok );
painter.translate( xs, ys );
painter.rotate( angle );
painter.drawText( 0, 0, temp[3] );
//painter.drawText( xs, ys, temp[3] );
}
}
void edpForm::paintEvent(QPaintEvent *event)
{
double angle;
QPainter painter( this );
for( n = 0; n < paintLines.count(); ++n )
{
k = paintLines[n];
temp = k.split( "," );
xs = temp[0].toInt( &ok );
ys = temp[1].toInt( &ok );
xe = temp[2].toInt( &ok );
ye = temp[3].toInt( &ok );
painter.drawLine( xs, ys, xe, ye );
}
for( n = 0; n < paintLabels.count(); ++n )
{
k = paintLabels[n];
temp = k.split( "," );
xs = temp[0].toInt( &ok );
ys = temp[1].toInt( &ok );
angle = temp[2].toDouble( &ok );
painter.translate( xs, ys );
painter.rotate( angle );
painter.drawText( 0, 0, temp[3] );
//painter.drawText( xs, ys, temp[3] );
}
}
To copy to clipboard, switch view to plain text mode
With the code as shown, I get the label s1, rotated to the angle of the line and at the midpoint of the line. The other two lines are not labeled.
Bookmarks