2 Attachment(s)
A small annoying problem in my QGraphicsScene
I already asked a question about this application.
I'm designing a chess application (with extended controls), but the movement of the peaces take place in a QGraphicsScene, designed to hold the board.
The board is sharp and pretty without movements :
Attachment 8628
When I move an element (next to the frame) this happens :
Attachment 8629
Parts of the code related to this :
Code:
#ifndef ChessElement_H
#define ChessElement_H
#include <QGraphicsItem>
{
public:
char type;
char identity;
int color;
int rank;
bool isOccupied;
bool movflag;
int rawCount;
int rawRank;
public : ChessElement
(QImage*,
int,
bool,
char,
int,
char,
int,
int);
public :QRectF boundingRect
() const ;
};
#endif // ChessElement_H
Paint function :
Code:
QRectF ChessElement
::boundingRect() const {
}
{
painter->drawImage(*s,*g);
delete s;
}
what is causing this white space ? I is it related to the re-drawing of items after movement.
Re: A small annoying problem in my QGraphicsScene
I guess is that the order of the items is causing this.
Re: A small annoying problem in my QGraphicsScene
Santosh Reddy, thank you for replying.
When I minimize the window & enlarge, the white space is removed, the board becomes normal again.
I placed the frame as the first element in the scene.
Re: A small annoying problem in my QGraphicsScene
It makes me think there is some problem with either boundingRect() or with paint()
Try with this version of drawImage()
Code:
void QPainter::drawImage ( const QPointF & point,
const QImage & image,
const QRectF & source, Qt
::ImageConversionFlags flags
= Qt
::AutoColor )
source rect will be the bounding rect
Re: A small annoying problem in my QGraphicsScene
Thank you very much. I will try this function once I'm done with scanning the code again for missing things.
I'm very sorry but I have another question : my program was initially 13 MB, now its size has increased to 14.8 MB, is that too much for a chess game ?
I mean in your experience : do you think such application can be built with lesser size ? (using the same quality & extensions of images I used here ?? )
and if I used Qt's native painting functions to paint my chess elements, would it be lesser in size ?
Extensions used : PNG.
Quality : 100% (photoshop)
Re: A small annoying problem in my QGraphicsScene
Are you embedding images as resources in the exe file, if so check there size too