Salut!

Je recois le message d'erreur suivant: "Error : 'objet->MyProxy::rotationY' cannot be used as a function".

Voici les codes:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
class MyProxy : public QGraphicsProxyWidget
{
public:
    MyProxy();
    qreal rotationY();
    void setRotationY(qreal rotation);
    QPointF center();
private:
    qreal m_rotationY;
    QPointF m_center; 
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
#include "MyProxy.h"
 
MyProxy::MyProxy()
{
   setFlag(Itemismovable);
}
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class MaScene: public QMainWindow
{
    Q_OBJECT
 
public:
    MaScene();
    ~MaScene();
 
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
 
public slots:
    void updateScene();
    void placeItem(MyProxy *objet);
 
 
private:
    QGraphicsProxyWidget *m_monProxy;
    QGraphicsScene *m_scene;
    QGraphicsView *m_view;
    QList<MyProxy *> m_objets;
 
};
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "MaScene.h"
#include "MyProxy.h"
 
MaScene::MaScene()
{
    QWebView *web = new QWebView;
    web->load(QUrl("http://www.7sur7.be"));
    web->show();
 
 
 
    m_scene = new QGraphicsScene(this);
 
 
    m_scene->setSceneRect(0, 0, 1000, 800);
 
    m_monProxy = new QGraphicsProxyWidget();
    m_monProxy->setWidget(web);
 
    m_scene->addItem(m_monProxy);
 
    QTransform matrix;
    matrix.rotate(30, Qt::YAxis);
    matrix.translate(20, 30);
    m_monProxy->setTransform(matrix);
 
    m_view = new QGraphicsView();
    m_view->setScene(m_scene);
 
    setCentralWidget(m_view);
 
    QTimer *timer = new QTimer(this);
    timer->setInterval(30);
    connect(timer, SIGNAL(timeout()), this, SLOT(updateScene()));
    timer->start();
 
}
 
void MaScene::updateScene()
{
    foreach (MyProxy *item, m_objets)
    {
        placeItem(item);
    }
}
 
void MaScene::placeItem(MyProxy *objet)
{
    QTransform m;
    m.rotate(objet->rotation(), Qt::YAxis);
    m.translate(objet->center().x(), objet->center().y());
    m.translate(-objet->largeur(), -objet ->hauteur());
    objet->setTransform(m);
}
 
void MaScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if(event->buttons() & Qt::LeftButton)
    {
        QPointF delta(event->scenePos() - event->lastScenePos());
        qreal rotation = delta.x();
        MyProxy->setRotation(rotation);
 
        QTransform matrix;
        matrix.rotate(MyProxy->rotation(), Qt::YAxis);
        MyProxy->setTransform(matrix);
    }
}