I'm facing some kind of mystery :
if( itemSelectionne->parentItem()->type() == NodeType) {
((GraphicsScene*) this->scene())->unselectAll();
itemSelectionne->parentItem()->setSelected(true);
//Coordinate of my toolbar, works fine
int centreX = itemSelectionne->pos().x() +
itemSelectionne->boundingRect().center().x();
int centreY = itemSelectionne->pos().y() +
itemSelectionne->boundingRect().center().y();
QPointF point = this->mapFromScene(
itemSelectionne->mapToScene(QPoint(centreX, centreY))
);
_nm.move(point.x(), point.y());
_nm.show((GraphicsNodeItem*) itemSelectionne->parentItem());
}
fter a mouse click on a QGraphicsView, I enter this piece of code to show my QToolbar (_nm is a custom object that containt 2 QToolbar. Show(...) call the show() on the QToolbar ) The first time I enter the if and call show() the QToolbar does't show up. But it shows up on the second click and every other click after.
Any idea where it could come from ?
Thx
Edit : That's the function I call in my custom class. _currentNode is a pointer to a custom QGraphicsItemGroup subclass.
void NodeMenu::show(GraphicsNodeItem * node) {
_currentNode = node;
_menuTop.show();
_menuBottom.show();
}
Found a solution :
I added in the constructor of my custom object the following:
_menuTop.show();
_menuBottom.show();
I don't know if it's a good solution but It works for me.