QGraphicsScene::drawItems is not called if it's subclassed
Hi,
I have my subclassed graphicsview and graphicsScene, all works perfectly with more or less 100 graphicsitems and some logic implemented in my custom scene.
I want to control when the items appear, so I tried to subclass QGraphicsScene::drawItems. But when QGraphicsView::drawItems is called it does not go to my subclassed scene, it calls QGraphicsScene::drawItems.
I can solve it writting my code directly in the view... but I would like to ask if it's the normal behavour or I'm missing something.
Thanks!
Re: QGraphicsScene::drawItems is not called if it's subclassed
Quote:
Originally Posted by
jano_alex_es
But when QGraphicsView::drawItems is called it does not go to my subclassed scene, it calls QGraphicsScene::drawItems.
QGraphicsView calls drawItems of the scene that is added to the view, thus your custom scene.
This in turn means that you did something wrong in your scene subclass.
Post your code.
Re: QGraphicsScene::drawItems is not called if it's subclassed
Quote:
QGraphicsView calls drawItems of the scene that is added to the view, thus your custom scene.
that's the problem... but it doesn't :S
Code:
MainWindow
::MainWindow(QWidget *parent
){
setWindowTitle("PruebaMagnetica1");
m_pScene = new CScene();
m_pView = new CView(m_pScene, this);
...
}
View.h
Code:
{
public:
CView
(CScene
* pScene,
QWidget * parent
= 0);
virtual ~CView();
void enableRendering(){m_bRender = true;}
protected:
bool m_bRender;
};
View.cpp
Code:
CView
::CView(CScene
* pScene,
QWidget * parent
){
setParent(parent);
setScene(pScene);
m_bRender = false;
}
CView::~CView()
{
// TODO Auto-generated destructor stub
}
{
if(m_bRender)
{
QGraphicsView::drawItems(painter, numItems, items, options
);
//It calls QGraphicsScene::drawItems instead of CScene::drawItems m_bRender = false;
}
}
Re: QGraphicsScene::drawItems is not called if it's subclassed
Re: QGraphicsScene::drawItems is not called if it's subclassed
because I have it subclassed as well in "CScene". But debugging it goes into QGraphicsScene class and not into the subclassed one.
Scene.h
Code:
{
Q_OBJECT
public:
virtual ~CScene();
protected:
Scene.cpp
Code:
{
//
//my code here, with a not called breakpoint
//
}
Re: QGraphicsScene::drawItems is not called if it's subclassed
Can you post the line of code where you set the breakpoint?
Some debuggers don't break on certain lines of code.
Re: QGraphicsScene::drawItems is not called if it's subclassed
I tried using traces as well :(
For instance, if I try this in order to test:
Code:
{
QGraphicsScene::drawItems(painter, numItems, items, options
);
//breakpoint }
doesn't work either
Re: QGraphicsScene::drawItems is not called if it's subclassed
just in case, some extra info: I'm using Visual Studio 2008 with Qt 4.5.0 (unfortunatly I can't update)
Re: QGraphicsScene::drawItems is not called if it's subclassed
Your method has an incorrect signature, you are missing the last argument (QWidget pointer).
Re: QGraphicsScene::drawItems is not called if it's subclassed
buf, I'm so stupid... thanks :)