View Single Post
Posts: 466 | Thanked: 661 times | Joined on Jan 2009
#5
Originally Posted by pichlo View Post
Is reviving a 3yo thread better or worse than creating a new one?

Anyway, I have a QScrollArea that covers most of the screen. Inside it, I have a widget of type Preview, derived from QGLWidget.

I also have zoom buttons. Zoom affects the horizontal size only, the vertical dimension is fixed. The problem is that zooming in more than two times segfaults the program.

Here is the relevant bit where it segfaults:
Code:
void Preview::paintGL ()
{
  QPainter painter(this);
  painter.setRenderHint(QPainter::Antialiasing, true);

  const int w = width();
  const int h = height();

  // Paint the background
  painter.fillRect(0, 0, w, h, Qt::white);

  // ... a few dozen more lines ...

  painter.end();
}
It crashes on the painter.fillRect line, as verified by sticking qDebug before and after. Values of w and h were:

w=668, h=416, OK (starting point)
w=1002, h=416, OK (zoom in x1)
w=1503, h=416, OK (zoom in x2)
w=2254, h=416, crash!

What is going on? Can the device not handle painting areas of that size? (Code written, built and run entirely on the phone.)

Given the experience, I am inclined to rewrite the code to eliminate QScrollArea altogether and instead do my own redrawing the preview with moving starting point. What options do I have to drag the picture left or right with the finger? I would really prefer not to try implementing my own version of kinetic scrolling if I can.
Interesting problem. I haven't done Qt in a while. Do you have any source to test with? Is this Maemo 5?

You may also find hints in the Qalendar source code. The author does a lot of his own drawing in there. Very clean code.
 

The Following 2 Users Say Thank You to jackburton For This Useful Post: