Behavior of paint method in QGraphicsItem
hello,
when i inherit QGraphicsItem class and implement paint method,i am getting a problem,
the paint method is being called twice.What is the reason??
ie.
- @{
@}
gives me the following output
i entered once:
i entered once:
What is the reason for this?And how can i avoid this…
5 replies
/*this is the code*/
- #include <QtGui/QApplication>
- #include "mainwindow.h"
- #include "QGraphicsItem"
- #include "stdio.h"
- #include "QGraphicsScene"
- #include "QGraphicsView"
- {
- public:
- Draw();
- };
- Draw::Draw()
- {
- }
- {
- }
- {
- }
- {
- printf("Entered once:\n");
- }
- int main(int argc, char *argv[])
- {
- Draw *mouse=new Draw();
- QGraphicsScene scene;
- scene.setSceneRect(0, 0, 500, 500);
- mouse->setPos(10,10);
- scene.addItem(mouse);
- view.show();
- return a.exec();
- }
Output
Entered once
Entered once
[EDIT: code formatting cleanup, Volker]
This article [thesmithfam.org] might help.
You must log in to post a reply. Not a member yet? Register here!




