Ok I've been learning how to add widgets dynamically to QGraphicsScene and I almost got it. I have encountered an issue when trying to set the position of a widget, as the (0,0) point of the widget is in the top left corner and I need it to be in the center.
I have
QWidget *mySprite;
//it has the paintEvent which draws everything I need QGraphicsWidget *wdg=scene->addWidget(mySprite);
//but now when I try to
wdg->rotate(90);
//it does so about top left point (0,0). And doing
wdg->translate(100,100);
//doesn't seem to help. It actually appears that it moves the whole widget instead of moving the reference point
QWidget *mySprite;//it has the paintEvent which draws everything I need
QGraphicsWidget *wdg=scene->addWidget(mySprite);
//but now when I try to
wdg->rotate(90);
//it does so about top left point (0,0). And doing
wdg->translate(100,100);
//doesn't seem to help. It actually appears that it moves the whole widget instead of moving the reference point
To copy to clipboard, switch view to plain text mode
Any ideas how I can set the center point of my QGraphicsWidget?
Thanks
Edit: Also, how should we use QVector<QGraphicsWidget*> when trying to access properties of the graphics widgets? Should we use a for loop or should we use a foreach loop? (I've never used the latter before)
Bookmarks