I am using QGraphicsProxyWidget objects (A & B) to represent some regular GUI elements such as comboxboxes in my QGraphicsScene. Those proxy objects (from a logical point of view) are linked to a regular QGraphicsItem instance C.
At some point in my application I need to ensure that this item C plus its proxy objects A & B has a higher Z level than the surrounding elements. However, when I try to loop over all children (and grandchildren) of my item C, the proxy elements never get accessed and therefore the Z value never gets updated => my item C has a new Z value, the proxies A & B do not and are therefore obscured.
I am currently adding the proxies like this:
m_pProxy = m_pScene->addWidget(pCombobox);
The problem was that the proxies A & B are not actually child objects of the item C, if added with the code fragment from the question. If a direct relationsship is required, the proxies need to be added as follows:
m_pProxy = new QGraphicsProxyWidget(pItem);
m_pProxy->setWidget(pCombobox);
m_pScene->addItem(m_pProxy);
By manually creating the proxy object, you can specify the desired parent element (here the regular item C) and then add it to the scene. As a result looping over its child elements now returns the proxies as well and their Z value can be chaned as needed.