I defined the struct as:
@class Joystick : public QObject, public QGraphicsEllipseItem
{
Q_OBJECT
public:
Joystick(int posx, int posy, int radiusvalues, bool fixX=false, bool fixY=false);
private:
signals:
void updateSticks(int x, int y);
public slots:
void updatedSticks(int t, int y);
};@
@Joystick::Joystick(int x, int y, int radiusLimitParam, bool fixX, bool fixY)
: QGraphicsEllipseItem(0, 0, 100, 100)
{
//...
//do stuff
//...
stick = new StickItem(this, fixX, fixY);
}@
@class StickItem : public QObject, public QGraphicsEllipseItem
{
Q_OBJECT
public:
Stick( QGraphicsItem * parent = 0, bool fixX=false, bool fixY=false);
private:
signals:
void updateSticks(int x, int y);
};@
@int main(int argc, char **argv)
{
QGraphicsScene scene;
QGraphicsView view(&scene);
left = new Joystick(/*...*/)
right = new Joystick(/*...*/)
scene.addItem(left);
scene.addItem(right);
//...
//do stuff
//...
return app.exec();
}@
My last doubt (I hope lol) is how I should set the Joystick position and size instead of use the fix values? Instead of QGraphicsEllipseItem(0, 0, 100, 100) can I create it with all zeros, and after set the position and size? something like:
@Joystick::Joystick(int x, int y, int radius, bool fixX, bool fixY)
: QGraphicsEllipseItem(0, 0, 0, 0)
{
this.setRect(x,y,radius,radius)
//...
//do stuff
//...
stick = new StickItem(this, fixX, fixY);
}@
To change the height and width of the ellipse it is normal to use setRect?