[Qt-interest] setParentItem() is hanging
trinathpujari
trinathpujari at tataelxsi.co.in
Fri Feb 19 10:06:14 CET 2010
Hi Andre,
Thanks for your replies....
I will elaborate what i am trying to do with my code.
I have one symbol screen and on the top of that screen, one
symbol line is there where i will show the symbols which is selected in
the symbol screen.
symbol screen as well as symbol line are both derived from
qgraphicswidget.
I am creating the symbol line and adding that it to the
symbol screen, so i can display on the screen at a time.
And any update to symbol screen automatically updates the
symbol line also.In this scenario i am using setParentItem( )
And the function where i am using the same is in below, I
tried to elaborate in the function which line is doing what...
Hope this will clarify and solve the problem....
If you have any kind of clarification then please reply me....
> void CPanel::setSymbolMode( )
> {
> /* Creating the symbol overlay */
> if ( m_pSymbolOverlay == NULL )
> {
> /*Creating the object of SymbolOverlay and screenInfo
> will hold the geometry of symbol screen*/;
> SCREEN_SIZE screenInfo =
> CViewManager::getVM()->getDisplayInfo();
> m_pSymbolOverlay = new CSymbolOverlay();
> /*Setting up the geometry for OverlayScreen*/
>
> m_pSymbolOverlay->setGeometry(screenInfo.apparea.symbolarea_dim.left,
>
> screenInfo.apparea.symbolarea_dim.top,
>
> width,
>
> height);
/* first we tried this setParentItem,but it was hanging at this
particular line.
* m_pSymbolOverlay->setParentItem(m_pSelf); //*m_pSelf is a pointer
to current screen*//*
}
/* setParentItem() was hanging so , we tried this alternate way to add
this symbol screen to the scene*/
if ( m_pSymbolOverlay != NULL )
{ /* Attach and show the symbol
window */
// Add CSymbolOverlay to scene
if(!CQTSurface::getQTSurface()->m_pScene->items().contains(m_pSymbolOverlay))
{
/*Adding Overlay object to the scene*/
CQTSurface::getQTSurface()->m_pScene->addItem(m_pSymbolOverlay);
}
m_pSymbolOverlay->setZValue(5);
m_pSymbolOverlay->setVisible(true);
m_pSymbolOverlay->show();
}
/*repainting the Overlay screen*/
m_pSymbolOverlay->repaint();
}
Regards
Trinath
André Somers wrote:
> Warnings in the documentation don't magically show up in the code, or in the
> compiler output.
> I would like to suggest that you show us what you try to do, with code,
> because there are many users that successfully use QGraphicsView, add items
> to scenes and parents, etc. I guess you're doing something wrong, but it's
> hard to see what if you don't show it to us.
>
> Note that an "undefined behavior" warning in the documentation is to be
> taken very seriously. You want to stay away from that. Really. Your program
> might end up eating your babies, so to speak.
>
> André
>
>
> -----Oorspronkelijk bericht-----
> Van: trinathpujari [mailto:trinathpujari at tataelxsi.co.in]
> Verzonden: donderdag 18 februari 2010 12:41
> Aan: Andre Somers
> CC: Qt-interest
> Onderwerp: Re: [Qt-interest] setParentItem() is hanging
>
> Hi Andre,
>
> Thanks for your earliest reply....
>
> Actually we are now trying to replace
> QGraphicsItem::setParentItem( ) with QGraphicsScene::addItem(object)
> which will add the object directly to the scene but this is also not
> working and regarding your query about warning,
>
>
>> Calling this function on an item that is an ancestor of parent have
>>
> undefined behaviour.
>
> No warning is coming in my code. If you know some alternative solution
> for the same please help me.
>
> Regards
> Trinath
>
>
>
> Andre Somers wrote:
>
>> trinathpujari wrote:
>>
>>
>>> Hi All,
>>>
>>> When i am using setParentItem(), screen is hanging at the point
>>> of setParentItem() function call.
>>> Can anybody tell any other way of implementing the setParentItem(
>>> ) function.
>>>
>>> Thanking in Advance
>>>
>>> Regards
>>> Trinath
>>>
>>>
>>>
>> It would have been helpful if you would have given slightly more
>> context, but I will assume for now that you are refering to
>> QGraphicsItem::setParentItem, as that seems to be the only function with
>> that name in Qt.
>>
>> Did you head the warning in the documentation?
>> > Calling this function on an item that is an ancestor of parent have
>> undefined behaviour.
>>
>> André
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>>
>
>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list