QGraphicsItem tooltip behavior
hi ppl,
I've got the following small prob:
Code:
#include <QtGui>
{
public:
~MyGraphicsItem(void){qDebug("delBand");}
return QRectF(0,
0, _width, _height
);
}
painter->setBrush(Qt::darkRed);
painter->setPen(Qt::black);
painter->drawRoundRect(0, 0, _width, _height);
}
private:
int _width;
int _height;
};
using:
Code:
setToolTip
(QString("testToolTip"));
in the constructor, works perfectly to enable tooltips for the item
but using:
does not work
why???:confused:
Re: QGraphicsItem tooltip behavior
because QGraphicsItem::tooltip is not virtual.
The view/scene will always call the base class version, which returns an empty string if you don't set any.
Regards
Re: QGraphicsItem tooltip behavior
Hi,
This post should be removed. Sorry.
Maverick
Re: QGraphicsItem tooltip behavior
Hi,
Ok...solved.
I have saved this post at the same time when the answer was given.
This post is not needed. I hope moderator or admin will remove it.
Maverick
Re: QGraphicsItem tooltip behavior
Quote:
Originally Posted by
marcel
because QGraphicsItem::tooltip is not virtual.
The view/scene will always call the base class version, which returns an empty string if you don't set any.
Regards
so there's no possibility to get the tooltip working without using setToolTip,
and to only to use a function like QString toolTip() const ?
Re: QGraphicsItem tooltip behavior
Quote:
so there's no possibility to get the tooltip working without using setToolTip,
and to only to use a function like QString toolTip() const ?
No.
But if you do a little of extra work, you might be able to show a tooltip when you want it to, but manually.
Hint: override QGraphicsScene::helpEvent.
Regards
Re: QGraphicsItem tooltip behavior
solved my prob the following way:
in constructor:
Code:
setAcceptsHoverEvents(true);
Code:
protected:
if (toolTip() != str){
setToolTip(str);
}
}
this does exactly, what I wanted,
but is a little long winded