char label[MAX_LABEL_LENGTH];
QList<double> lMajorTicks, lMinorTicks;
_pEngine -> buildTicks( _oAttribute._fStart, _oAttribute._fEnd, _nMaxMajorTickNumber, lMajorTicks, lMinorTicks );
int nCount = lMajorTicks.count();
for( int i = 0; i < nCount; i ++ )
{
int nPos = (lMajorTicks[i]-_oAttribute._fStart)*_fScale;
painter -> drawLine( nPos, _oAttribute._nMargin, nPos, _oAttribute._nMargin+_oAttribute._nMajorTickLen );
memset( label, '\0', MAX_LABEL_LENGTH );
sprintf( label, _oAttribute._sMajorLabelFormat, lMajorTicks[i] );
QRect rc
= painter
-> boundingRect
( QRect(0,
0,
0,
0), Qt
::AlignCenter, text
);
QRect qrc
= QRect( nPos, _oAttribute._nMargin
+_oAttribute._nMajorTickLen
+15, rc.
width()+10, rc.
height()+10 );
if( i > 0 && i < nCount-1);
painter -> drawText( qrc, Qt::AlignCenter, text );
}
char label[MAX_LABEL_LENGTH];
QList<double> lMajorTicks, lMinorTicks;
_pEngine -> buildTicks( _oAttribute._fStart, _oAttribute._fEnd, _nMaxMajorTickNumber, lMajorTicks, lMinorTicks );
int nCount = lMajorTicks.count();
for( int i = 0; i < nCount; i ++ )
{
int nPos = (lMajorTicks[i]-_oAttribute._fStart)*_fScale;
painter -> drawLine( nPos, _oAttribute._nMargin, nPos, _oAttribute._nMargin+_oAttribute._nMajorTickLen );
memset( label, '\0', MAX_LABEL_LENGTH );
sprintf( label, _oAttribute._sMajorLabelFormat, lMajorTicks[i] );
QString text = QString::fromStdString( label );
QRect rc = painter -> boundingRect( QRect(0,0,0,0), Qt::AlignCenter, text );
QRect qrc = QRect( nPos, _oAttribute._nMargin+_oAttribute._nMajorTickLen+15, rc.width()+10, rc.height()+10 );
if( i > 0 && i < nCount-1);
painter -> drawText( qrc, Qt::AlignCenter, text );
}
To copy to clipboard, switch view to plain text mode
If the drawText() is commented off, the program is ok, or it crashes.
Bookmarks