PDA

View Full Version : Issue with contains(const QPointF& a_point) in QGraphicsItem in Qt4.4.0



findima
1st October 2008, 13:44
Hi,
I have overriden a class from QGraphicsItem in Qt4.4.0. In that class, i have overriden the function
contains(const QPointF& a_point) . This contains(const QPointF& a_point) function was overriden for selecting of the item. So when i move the mouse over the graphicsItem, that function should get called.

I have seen that with Qt4.4.0, the contains(const QPointF& a_point) function is not getting called, whereas with Qt4.2.2 , the contains(const QPointF& a_point) function is getting called.

Please let me know if anybody knows the answer .

caduel
1st October 2008, 13:49
make sure you have not forgotten the "const" in the function's signature

findima
3rd October 2008, 07:52
Thanks for replying.
I have put the const in the function signature contains(const QPointF& a_point)
Actually, the same piece of code I am tring to compile with Qt4.4 and Qt4.2.
In Qt4.2 , it enters the contains function but in Qt4.4 it does not enter the contains function.

Please let me know if anybody knows the answer.
Thanks

caduel
3rd October 2008, 09:19
just to make sure: I mean the 2nd const:

bool contains ( const QPointF & point ) const

findima
3rd October 2008, 10:20
Hi,
Thanks for replying me.
There is only one Qt function bool contains(const QPointF& a_point) const in QGraphicsItem which i am overriding. It gets called in Qt4.2 but does not gets called in Qt4.4 when i override.
The same pice of code i am using for both Qt4.4 and Qt4.2 .

Please let me know if you know the answer

Thanks

wysota
3rd October 2008, 12:37
Maybe it doesn't need to be called?

findima
7th October 2008, 12:14
Hi,
The problem is that it if i dont override that function, i am not able to do selection of the item.
I have to override this function to do selection of the item because it needs to know whether the mouse is over the item or not.

The item is our own derived item from QGraphiceItem . Its a vector of points .
Please suggest me if there is any other function similar to contains function in Qt4.4 which I can override .