Если вы наследуете от QGraphicsObject ... Я приведу здесь пример:
Declare:
class Text : public QGraphicsObject
{
Q_OBJECT
public:
Text(QGraphicsItem * parent = 0);
void paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option, QWidget * widget );
QRectF boundingRect() const ;
void timerEvent ( QTimerEvent * event );
protected:
QGraphicsTextItem * item;
int time;
};
реализация:
Text::Text(QGraphicsItem * parent)
:QGraphicsObject(parent)
{
item = new QGraphicsTextItem(this);
item->setPlainText("hello world");
setFlag(QGraphicsItem::ItemIsFocusable);
time = 1000;
startTimer(time);
}
void Text::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option, QWidget * widget )
{
item->paint(painter,option,widget);
}
QRectF Text::boundingRect() const
{
return item->boundingRect();
}
void Text::timerEvent ( QTimerEvent * event )
{
QString timepass = "Time :" + QString::number(time / 1000) + " seconds";
time = time + 1000;
qDebug() << timepass;
}
удачи