If I add my subclassed QGraphicsItem before I add anything else to the scene everything works fine. But if I add something else before then the paint method is never triggered in my new QGraphicsItem. Can somebody explain what I am missing?
{
void MyScene::toggleSymbols()
{
if(bSymbols)
{
qDebug("false");
bSymbols = false;
}
else
{
qDebug("true");
bSymbols = true;
symbols = new itemSymbols(); //Subclassed QGraphicsItem
QPointF centerPos
= QPointF(this
->sceneRect
().
width()/2, this
->sceneRect
().
height()/2);
symbols->setCenterPos(centerPos);
addItem(symbols);
}
}
}
MyScene::MyScene(QObject *parent)
: QGraphicsScene(parent), currentDrawItem(NULL), bDraw(false)
{
void MyScene::toggleSymbols()
{
if(bSymbols)
{
qDebug("false");
bSymbols = false;
}
else
{
qDebug("true");
bSymbols = true;
symbols = new itemSymbols(); //Subclassed QGraphicsItem
QPointF centerPos = QPointF(this->sceneRect().width()/2, this->sceneRect().height()/2);
symbols->setCenterPos(centerPos);
addItem(symbols);
}
}
}
To copy to clipboard, switch view to plain text mode
{
{
Debug("itemSymbols paint()");
}
}
itemSymbols::itemSymbols() : QGraphicsItem()
{
void itemSymbols::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Debug("itemSymbols paint()");
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks