Results 1 to 7 of 7

Thread: A strange problem with QGraphicsSvgItem

  1. #1
    Join Date
    Jul 2008
    Posts
    10
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Unhappy A strange problem with QGraphicsSvgItem

    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:

    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?
    Attached Images Attached Images

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A strange problem with QGraphicsSvgItem

    Can you show us the code for what u are doing on item selected and item deselected ??

  3. The following user says thank you to aamer4yu for this useful post:

    Justin_W (21st July 2008)

  4. #3
    Join Date
    Jul 2008
    Posts
    10
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: A strange problem with QGraphicsSvgItem

    I don't know the principle of how the dashed-line frame is shown very clearly.
    I just set the flag "ItemIsSelectable" to Item in construct function:
    Qt Code:
    1. SvgShapeItem(QString &Name,QString &File,Mode mode,QMenu *ContextMenu,QGraphicsItem *parent=0): QGraphicsSvgItem(File,parent)
    2. {
    3. ShapeName=Name;
    4. FileName=File;
    5. myMode=mode;
    6. myContextMenu=ContextMenu;
    7. setFlag(QGraphicsItem::ItemIsMoveable,true);
    8. setFlag(QGraphicsItem::ItemIsSelectable,true);
    9. }
    To copy to clipboard, switch view to plain text mode 
    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!
    Last edited by jpn; 21st July 2008 at 18:02. Reason: missing [code] tags

  5. #4
    Join Date
    Jul 2008
    Posts
    10
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: A strange problem with QGraphicsSvgItem

    Quote Originally Posted by aamer4yu View Post
    Can you show us the code for what u are doing on item selected and item deselected ??
    Qt Code:
    1. SvgShapeItem(QString &Name,QString &File,Mode mode,QMenu *ContextMenu,QGraphicsItem *parent=0): QGraphicsSvgItem(File,parent)
    2. {
    3. ShapeName=Name;
    4. FileName=File;
    5. myMode=mode;
    6. myContextMenu=ContextMenu;
    7. setFlag(QGraphicsItem::ItemIsMoveable,true);
    8. setFlag(QGraphicsItem::ItemIsSelectable,true);
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 21st July 2008 at 18:02. Reason: missing [code] tags

  6. #5
    Join Date
    Jul 2008
    Posts
    10
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: A strange problem with QGraphicsSvgItem

    And I added a QGraphicsPolygonItem with the same method, there' no such problem with QGraphicsPolygonItem,is it a dug of QT?

  7. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: A strange problem with QGraphicsSvgItem

    Am not sure if its a prob with svg items.
    What are u doing in the paint() function of the svg item ??

  8. #7
    Join Date
    Jul 2008
    Posts
    10
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: A strange problem with QGraphicsSvgItem

    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.

Similar Threads

  1. QGraphicsSvgItem, problem with scaling (invalid bounding rect)
    By Józef Paczenko in forum Qt Programming
    Replies: 3
    Last Post: 8th June 2010, 08:58
  2. Very Strange problem
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2008, 09:20
  3. Problem with QGraphicsSvgItem
    By drake1983 in forum Newbie
    Replies: 1
    Last Post: 8th July 2007, 07:05
  4. Strange shortcut problem
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2007, 10:26
  5. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 10:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.