0

So i hope someone can help me again with the following. I want to use a pointer from one class in another one.

car.h

class wheel;

class car : public QMainWindow
{
public:
    car (QWidget *parent = 0);

    wheel *test;
};

class wheel : QGraphicsPixmapItem
{
public:
    wheel();

    void hoverEnterEvent (QGraphicsSceneHoverEvent*);
};

car.cpp

#include "car.h"

wheel::wheel()
{

}

car::car (QWidget*)
{
    test = new wheel;
    test -> setAcceptHoverEvents (true);
}

wheel::hoverEnterEvent (QGraphicsSceneHoverEvent*)
{
    test -> setPixmap (/*thePixmap*/);
}

The problem is, i cant use the pointer "test" in class wheel, and i really dont know how i can do this "without" making the pointer "test" global.

user1533754
  • 19
  • 1
  • 7

1 Answers1

2

wheel::hoverEnterEvent is part of the wheel class. It doesn't need a pointer to itself to operate on itself, so just replace

test -> setPixmap (/*thePixmap*/);

with

setPixmap (/*thePixmap*/);
Chris
  • 17,119
  • 5
  • 57
  • 60