QGraphicsItem doesn't inherit QObject?
in the documentation there's a sample that inherits both QObject and QGraphicsItem. Deoesn't QGraphicsItem inherits QObject? I looked at the Qt Assistant but it doesn't give info about that.
Code:
{
Q_OBJECT
public:
Mouse();
protected:
private:
qreal angle;
qreal speed;
qreal mouseEyeDirection;
};
Re: QGraphicsItem doesn't inherit QObject?
No, QGraphicsItem doesn't inherit QObject. It would be too heavy then.
Re: QGraphicsItem doesn't inherit QObject?
And what about signals and slots? How we can emit signals and connect them to slots?
Standard QObject::connect will not work. At least it doesn't work in my project, when I try to send the signal from the item to QWidget(every time I've got doesn't match -error).
Re: QGraphicsItem doesn't inherit QObject?
Signals and slots require QObject legacy. You can use QGraphicsObject for custom items or subclass existing graphics item classes and derive them from QObject as well.
Re: QGraphicsItem doesn't inherit QObject?
Thank you. I guess, it's only way for getting signals and doing the project in a right way.
Re: QGraphicsItem doesn't inherit QObject?
No, it's not the only way. You can have a separate controller object that will emit signals on behalf of your items. Then you don't have to modify the item classes and they will remain to be light as you'll only have one object that emits signals for all your items.
Re: QGraphicsItem doesn't inherit QObject?
Oh, I didn't consider that at all. Thank you once again for helping. I need to try your advice.