0

I have a QGraphicscene that don't update screen with negative numbers.The image explain all.

http://s16.postimage.org/4b59m8hx1/problem.jpg

That's the simple code.

if (dinA){ //assume its always true
      int sx=dinA->getX();
      int sy=dinA->getY();
      dis->scene.addRect(QRectF(300,100-sy, sx, sy),QPen(), QBrush(Qt::FDiagPattern));
 }

 //** 300,100-sy ** because of my work-area is 600*300

What could be the cause?

Tcz
  • 661
  • 5
  • 18

1 Answers1

0

If I interpret your screenshot and the text below it correctly, you are using a negative number for the height. However, this creates an invalid QRectF. Citing from the Qt documentation:

bool QRectF::isValid() const
[...]
A valid rectangle has a width() > 0 and height() > 0.

In the your code, you should make sure that the size and the width are positive. Otherwise, you have to swap the x- and/or y-coordinate of the corner points.

Hope that helps!

Mehrwolf
  • 8,208
  • 2
  • 26
  • 38