Have not looked in detail at your code, but one things stands out: Allocating the QLineF arrays every time you draw the background (line 70 in your code). This will eventually really fragment memory and could cause your program to crash when the memory manager can't find enough for the next allocation.

So instead of creating the array on the heap (with "new"), just allocate it on the stack:

Qt Code:
  1. size_t n = size_t(l - f + 1);
  2. QVector< QLineF > arr( n );
  3. double lineX = fx;
  4. for(std::size_t i = 0; i < n; i++)
  5. {
  6. arr[i] = QLineF(lineX, t, lineX, b);
  7. lineX += hourOffset;
  8. }
  9.  
  10. painter->setPen(linePen);
  11. painter->drawLines( &(arr[0]), int(n));
To copy to clipboard, switch view to plain text mode