[solved] paint method from QDeclarativeItem gets not called
-
Hi,
I have an item, which subclasses QDeclarativeItem. But the paint method doesn't get called.
The following signature of the paint method is used:
@void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);@
I also try to force a repaint with calling update on my component, but the paint won't be called (I have some qDebug outputs to see if the method gets called as well as a simple std::cout, but nothing happens).
Anyone an idea where my error is? I have other components I paint the same way, but these ones work as intended.
I cleaned up my build environment, but nothing works.
-
Have you tried debugging? Or is it too complicated in that case?
-
Sure but it doesn't help me much, because my paint doesn't get called at all. (Breakpoint is set in ctor, the line where update is called as well as in paint itself (first line of paint)) .
-
Ok very stupid error: I forgot the following line in my ctor:
@setFlag(QGraphicsItem::ItemHasNoContents, false);@
Now it paints, not the way I want him to but ok that's the next step to fix that. -
Hi. I have a similar problem in reimplementing QDeclarativeItem . I have set the flag
@
setFlag(QGraphicsItem::ItemHasNoContents, false);
@in the constructor and implemented
@void DeclarativeChart::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)
{qDebug() <<"painter "; QRect rect(geometry.toRect()); m_chart->paint(p, rect);
}@
I have a bar diagram painted. The problem is that an original bar diagram is painted and the corrected bar diagram is written over the original and I got two bar diagrams superposed instead of just the right one.I have noticed, by the debug, that the paint method is called many times. I do not know if it is the right.
Thanks for any advice.
-
Hi, I have found the cause of the problem. I was using the QGraphicsProxyWidget together with the
@void DeclarativeChart::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget)@
Now I'm using just the QGraphicsProxyWidget because I was not able to do a pie-chart works otherwise.