Begin QGraphicsScene not from center, but from begining or how to make better
-
Hello, I have a problem with QGraphicsScene. I need to start it from the begining not from center. How can I do it? And is there a better solution? I tried to mathematically, but something else happens and when I change the size of qdialog something another happens( paints in another position relatively to cursor ). What I'm trying to make is simple paint, you press the button, what figure you want and then make 2 dots to draw that figure. Here's a part of the code that needs change:
@void MyPaint::mousePressEvent(QMouseEvent *event)
{
QString temp;
QPoint SomePoint = event->pos();
if( event->button() == Qt::LeftButton && view->cursor().shape() == Qt::CrossCursor )
{
switch( pointsNum )
{
case 0:
geom.push_back( QVector<QPoint>() );
PushBackPoint( event->pos() );break; case 1: PushBackPoint( event->pos() ); if( lineButClicked || ellButClicked || rectButClicked ) { Paint = true; this->update(); } break; } }
}
void MyPaint::paintEvent(QPaintEvent *pe)
{if( Paint ) { QPainter painter( this ); QPoint temp( view->pos() ); QPoint correct( view->rect().width() / 2, view->rect().height() / 2 ); if( lineButClicked ) { items.push_back( scene->addLine( QLine( geom[index][0] - temp - correct, geom[index][1] - temp - correct ) ) ); index++; pointsNum = 0; } else if( ellButClicked ) { scene->addRect( QRect( geom[index][0] - temp, geom[index][1] - temp ) ); index++; pointsNum = 0; } else if ( rectButClicked ) { scene->addEllipse( QRect( geom[index][0], geom[index][1] ) ); index++; pointsNum = 0; } Paint = false; }
}@
Thx for answering, and is it ok to ask multiple questions in one thread, cause I think I'll be stuck in bugs for a long time? :)