Пытаюсь по нажатию кнопки мыши подкрасить точку, но выдается в консоль ошибка(предупреждение)
Image::setPixel: Index число out of range
Вроде все правильно делаю
Помогите разобраться
Вот код
GraphicsSceneObstanovka::GraphicsSceneObstanovka(QObject *parent):
QGraphicsScene(parent)
{
//addPixmap(QPixmap(":resource/images/submarine_1500_390.bmp"));
gs = new GeneralSituation();
addItem(gs);
setSceneRect(itemsBoundingRect());
}
GraphicsSceneObstanovka::~GraphicsSceneObstanovka()
{
}
//-----------------------------------------------------------------------------------------
GeneralSituation::GeneralSituation(QGraphicsItem *parent):
QGraphicsObject(parent)
{
image = new QImage(":resource/images/submarine_1500_390.bmp");
}
GeneralSituation::~GeneralSituation()
{
}
QRectF GeneralSituation::boundingRect() const
{
return QRectF(0,0,submarina_width,submarina_height);
}
void GeneralSituation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->save();
painter->drawImage(0,0,*image);
painter->restore();
}
void GeneralSituation::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
qDebug()<<"mousePressEvent";
QPointF scenePoint = event->scenePos();
qDebug()<<"scenePoint = "<<scenePoint;
PointColor startPoint;
startPoint.X = (unsigned int)(scenePoint.x());
startPoint.Y = (unsigned int)(scenePoint.y());
delete image;
image = new QImage(":resource/images/submarine_1500_390.bmp");
image->setPixel(startPoint.X,startPoint.Y,0x00FFFF00U); //color 0x00FFFF00U
update();
}
Спасибо!