I am using painter->drawText() inside a for loop in a QGraphicsItem's paint method, and the text is being rendered till it gets to a certain coordinate where it stops rendering. It looks to be because the the value of the coordinate is too large? Interestingly the drawLine() has no problem with the coordinates above where the drawText fails and rendered correctly.



//-------------------------------------------------------------------------------
// TimeRulerItem:aint()
//
//-------------------------------------------------------------------------------
void TimeRulerItem:aint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(widget);

if(option->levelOfDetail < 0.05) {
return;
}

QColor fillColor = (option->state & QStyle::State_Selected) ? Bg.dark(150) : Bg;

if (option->state & QStyle::State_MouseOver)
fillColor = fillColor.light(125);

QColor color;
qreal width;
if (option->state & QStyle::State_MouseOver) {
color = QColor(Qt::yellow);
width = 1.0;
} else {
color = Fg;
width = 0.75;
}

painter->setFont(QApplication::font());
painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100)));
painter->setPen(QPen(color, width));

const QRectF exposed = option->exposedRect;

qDebug() << "\n\n\n";

qDebug() << "viewport:" << painter->viewport();
qDebug() << "window:" << painter->window();

qDebug() << "exposed:" << exposed;

const qreal ex_top = exposed.top();
const qreal ex_bot = exposed.bottom();
const qreal ex_left = exposed.left();
const qreal ex_right = exposed.right();
const qreal ex_height = exposed.height();
const qreal ex_width = exposed.width();

const qint64 num_ticks = EndTime - StartTime;

const qint64 start_tick = ex_left/TICK_WIDTH;
const qint64 end_tick = ex_right/TICK_WIDTH;

qDebug() << "start_tick:" << start_tick
<< ", end_tick:" << end_tick;

for(qint64 i = 0; i <= end_tick-start_tick; i++) {
qDebug() << "Drawing tick:" << i;

const qint64 time = i+StartTime;
const qint64 time_mod_10 = time%10;
qDebug() << " time:" << time << ", time_mod_10:" << time_mod_10;

// Draw the tick mod 10 lines:
if(time%10 == 0) painter->drawLine(i*TICK_WIDTH, TICK_HEIGHT, i*TICK_WIDTH, -2*TICK_HEIGHT);

// Draw tick mod 10
painter->setPen(QPen(color, width));
const QString time_str = QString::number(time);
const QString time_mod_10_str = QString::number(time_mod_10);
qDebug() << " time:" << time_str << ", time_mod_10:" << time_mod_10_str;

const qint64 x = i*TICK_WIDTH;
const qint64 x_1 = (i*TICK_WIDTH) + 1;
qDebug() << " x:" << x << ", x_1:" << x_1;

const qreal fx = x;
const qreal fx_1 = x_1;
qDebug() << " fx:" << fx << ", fx_1:" << fx_1;

const QPoint pt = QPoint(x , -1);
const QPoint pt_1 = QPoint(x_1, 11);
qDebug() << " pt:" << pt << ", pt_1:" << pt_1;

if(time%10 == 0) painter->drawText(pt, time_str);

// Draw tick
painter->drawText(pt_1, time_mod_10_str);
}
}