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 :
Screen shot 2013-01-26 at 6.09.56 PM.jpg
When I move an element (next to the frame) this happens :
Screen shot 2013-01-26 at 6.10.03 PM.jpg
Parts of the code related to this :
#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
#ifndef ChessElement_H
#define ChessElement_H
#include <QGraphicsItem>
Class QPainter;
class ChessElement : public QGraphicsItem
{
public:
QImage *g;
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 ;
public :void paint(QPainter*, const QStyleOptionGraphicsItem*,QWidget *);
};
#endif // ChessElement_H
To copy to clipboard, switch view to plain text mode
Paint function :
QRectF ChessElement
::boundingRect() const {
}
{
painter->drawImage(*s,*g);
delete s;
}
QRectF ChessElement::boundingRect() const
{
return QRectF(0,0,30,30);
}
void ChessElement:: paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
QPoint *s = new QPoint(0,0);
painter->drawImage(*s,*g);
delete s;
}
To copy to clipboard, switch view to plain text mode
what is causing this white space ? I is it related to the re-drawing of items after movement.
Bookmarks