PDA

View Full Version : A strange problem with QGraphicsSvgItem



Justin_W
20th July 2008, 15:30
:confused:I'm a beginner with Qt programming. I'm now programming a procedure about QGraphicsScene and QGraphicsSvgItem.But today i meet a very stange problem:I consider when one item(QGraphicsSvgItem in QGraphicsScene) is selected, there 's a dashed-line frame the item,isn't it?
i have set the flag:setFlag(QGraphicsItem::ItemIsSelectable,ture) ;
and the dashed-line did appeared.

But the problem is when the item is unselected,the dashed-line still shows!
Just like this:
http://www.qtcentre.org/forum/attachment.php?attachmentid=2397&stc=1&d=1216563917
I have writed some code to detect whether the items were unselected.
and it showed all the items were unselected.
but why they already have dashed-line frame?
who can tell me why?

aamer4yu
21st July 2008, 06:05
Can you show us the code for what u are doing on item selected and item deselected ??

Justin_W
21st July 2008, 07:00
I don't know the principle of how the dashed-line frame is shown very clearly.:confused:
I just set the flag "ItemIsSelectable" to Item in construct function:

SvgShapeItem(QString &Name,QString &File,Mode mode,QMenu *ContextMenu,QGraphicsItem *parent=0): QGraphicsSvgItem(File,parent)
{
ShapeName=Name;
FileName=File;
myMode=mode;
myContextMenu=ContextMenu;
setFlag(QGraphicsItem::ItemIsMoveable,true);
setFlag(QGraphicsItem::ItemIsSelectable,true);
}
and i have no other codes to select or deselect the item.I dont konw how?
Need i do something else?

Thanks a lot for your reply!:)

Justin_W
21st July 2008, 14:03
Can you show us the code for what u are doing on item selected and item deselected ??


SvgShapeItem(QString &Name,QString &File,Mode mode,QMenu *ContextMenu,QGraphicsItem *parent=0): QGraphicsSvgItem(File,parent)
{
ShapeName=Name;
FileName=File;
myMode=mode;
myContextMenu=ContextMenu;
setFlag(QGraphicsItem::ItemIsMoveable,true);
setFlag(QGraphicsItem::ItemIsSelectable,true);
}

Justin_W
21st July 2008, 16:37
And I added a QGraphicsPolygonItem with the same method, there' no such problem with QGraphicsPolygonItem,is it a dug of QT?

aamer4yu
22nd July 2008, 05:59
Am not sure if its a prob with svg items.
What are u doing in the paint() function of the svg item ??

Justin_W
23rd July 2008, 09:40
I did nothing with paint() function.What need i do in this function?
I find another strange thing that when i change the scale of QGraphicsView,the dashed-line box disappeared normally.