AtlasS
26th January 2013, 16:16
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 :
8628
When I move an element (next to the frame) this happens :
8629
Parts of the code related to this :
#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,in t);
public :QRectF boundingRect() const ;
public :void paint(QPainter*, const QStyleOptionGraphicsItem*,QWidget *);
};
#endif // ChessElement_H
Paint function :
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;
}
what is causing this white space ? I is it related to the re-drawing of items after movement.
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 :
8628
When I move an element (next to the frame) this happens :
8629
Parts of the code related to this :
#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,in t);
public :QRectF boundingRect() const ;
public :void paint(QPainter*, const QStyleOptionGraphicsItem*,QWidget *);
};
#endif // ChessElement_H
Paint function :
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;
}
what is causing this white space ? I is it related to the re-drawing of items after movement.