2012-04-21 18 views
0

我面對的某種神祕:在QToolBar不可見秀第二個呼叫/調用setVisible(真)之前

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()); 
} 

壓腳提升上的QGraphicsView鼠標點擊,我進入這段代碼展示我在QToolBar (_nm是一個自定義對象,包含2 QToolbar。Show(...)調用QToolbar上的show()) 第一次輸入if和call show()時,QToolbar不顯示。但它顯示在第二次點擊和其他每次點擊之後。

任何想法它可能來自哪裏?

THX

編輯:這是我在自定義類調用該函數。 _currentNode是一個指向自定義QGraphicsItemGroup子類的指針。

void NodeMenu::show(GraphicsNodeItem * node) { 
_currentNode = node; 

_menuTop.show(); 
_menuBottom.show(); 
} 
+0

我不認爲QWidget :: show()需要任何參數......該線應該做什麼,到底是什麼? – Anthony 2012-04-21 17:28:21

+0

對,這是因爲我的班級中包含的2個QToolbar對象的顯示調用(_nm由2個QToolbar組成) – 2012-04-21 17:33:10

+0

您可以發佈該功能嗎? – Anthony 2012-04-21 17:35:39

回答

0

找到了解決辦法:

我在自定義的構造函數中添加的對象如下:

_menuTop.show(); 
_menuBottom.show(); 

我不知道這是否是一個很好的解決方案,但它爲我工作。

相關問題