View Full Version : addRect doesn't plot specific data

18th February 2011, 08:10
I have a QGraphicsView *scene.
I'm plotting rectangles in the scene using addRect(x,y,h,w,QPen,QBrush)
I'm extracting this data from a file.
The problem is that the code works fine for one file but doesn't plot anything at all for another.
The file which is getting plotted has data:
x:-312 y:0 h:474 w:15
x:-398 y:20 h:398 w:15
x:-395 y:40 h:444 w:15
x:-309 y:60 h:431 w:15
x:-299 y:80 h:477 w:15
x:-322 y:100 h:461 w:15
x:-400 y:120 h:393 w:15
x:-378 y:140 h:434 w:15
x:-286 y:160 h:454 w:15
x:-345 y:180 h:464 w:15
x:-350 y:200 h:467 w:15
x:-302 y:220 h:421 w:15
x:-291 y:240 h:459 w:15
x:-279 y:260 h:431 w:15
x:-271 y:280 h:428 w:15
x:-276 y:300 h:439 w:15
x:252 y:300 h:225 w:15
x:-284 y:320 h:459 w:15
x:259 y:320 h:266 w:15
x:-398 y:340 h:395 w:15
And the file which is not getting plotted is as follows:
x:-400 y:0 h:220 w:15
x:-179 y:0 h:220 w:15
x:42 y:0 h:220 w:15
x:263 y:0 h:219 w:15
x:484 y:0 h:68 w:15
x:-400 y:20 h:220 w:15
x:-179 y:20 h:220 w:15
x:42 y:20 h:220 w:15
x:263 y:20 h:219 w:15
x:484 y:20 h:68 w:15
x:-400 y:40 h:220 w:15
x:-179 y:40 h:220 w:15
x:42 y:40 h:220 w:15
x:263 y:40 h:219 w:15
x:484 y:40 h:68 w:15
x:-400 y:60 h:220 w:15
x:-179 y:60 h:220 w:15
x:42 y:60 h:220 w:15
x:263 y:60 h:219 w:15
x:484 y:60 h:68 w:15
x:-400 y:80 h:220 w:15
Is something wrong with the data of the 2nd file? I cant figure out the problem....

18th February 2011, 10:56
Did you try to track the values you pass to the addRect method? Data parsing seems to be the only area that you might experience problems with.

18th February 2011, 11:16
You are doing data loading and apparently this is a problem. We don't see your code so we have no idea what is wrong here. I suspect that you have some error with file (incorrect file name - error with opening the file).
check qt logs - there you can see clues what can be wrong (run it form IDE to see it)
use debugger to check what is the problem
when nr 1 and 2 fails show your code