The problem is, with regard to m_pPushExpand being visible or not, that the geometry of m_pPushLeft is not updated until the editor widget is shown. So in your delegate's editorEvent() function, item->GetPushLeftGeometry() returns the previous position of the button.
I hope that makes sense.
As a test, try the following:
void TestTreeWidgetItem::RefreshWidget(TestTreeWidgetItemEditor *itemeditor, TestTreeWidget::ItemType type)
{
if(type == TestTreeWidget::ITTypeA)
{
itemeditor->m_plabelDescription->setText(m_strDescription);
itemeditor->m_pPushExpand->setVisible((childCount() > 0));
QRect rect
= itemeditor
->m_pPushLeft
->geometry
();
if(childCount()>0) rect.setX(338);
else rect.setX(380);
itemeditor->m_pPushLeft->setGeometry(rect);
itemeditor->m_pPushLeft->setStyleSheet("background: "+ m_strColor +";");
}
}
void TestTreeWidgetItem::RefreshWidget(TestTreeWidgetItemEditor *itemeditor, TestTreeWidget::ItemType type)
{
if(type == TestTreeWidget::ITTypeA)
{
itemeditor->m_plabelDescription->setText(m_strDescription);
itemeditor->m_pPushExpand->setVisible((childCount() > 0));
QRect rect = itemeditor->m_pPushLeft->geometry();
if(childCount()>0) rect.setX(338);
else rect.setX(380);
itemeditor->m_pPushLeft->setGeometry(rect);
itemeditor->m_pPushLeft->setStyleSheet("background: "+ m_strColor +";");
}
}
To copy to clipboard, switch view to plain text mode
Hard coding the position of the button won't work unless you set your main widget to a fixed size.
Bookmarks