Results 1 to 8 of 8

Thread: How to hide the dashed frame outside the QGraphicsItem .

  1. #1

    Question How to hide the dashed frame outside the QGraphicsItem .

    When you have select a QGraphcisItem in the QGraphicsScene,there is a dashed frame outside the Item .

    but I want to hide the dashed frame ,Please help me ...

    I am afraid these is no way to resolve it ...Thanks a lot..

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to hide the dashed frame outside the QGraphicsItem .

    Quote Originally Posted by robertkun View Post
    I am afraid these is no way to resolve it
    Thats easy, just set this flag to false.
    Qt Code:
    1. item->setFlag(QGraphicsItem::ItemIsSelectable, false);
    To copy to clipboard, switch view to plain text mode 
    Last edited by yogeshgokul; 6th August 2009 at 09:38.

  3. #3

    Cool Re: How to hide the dashed frame outside the QGraphicsItem .

    Quote Originally Posted by yogeshgokul View Post
    Thats easy, just set this flag to false.
    Qt Code:
    1. item->setFlag(QGraphicsItem::ItemIsSelectable, false);
    To copy to clipboard, switch view to plain text mode 
    Yes,that is ture,thank you . but if I have set the ItemIsSelectable false,How can I to select it .. Let me think think.thank you..

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to hide the dashed frame outside the QGraphicsItem .

    Quote Originally Posted by robertkun View Post
    but if I have set the ItemIsSelectable false,How can I to select it
    Re-Setting this flag, will not stop the item selection. It will just stop showing the rectangle. And this is what you want I guess.

  5. #5

    Red face Re: How to hide the dashed frame outside the QGraphicsItem .

    Now I am rewrite the function paint() of the QGraphicsPolygonItem,For example :
    Qt Code:
    1. void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
    2. QWidget *widget)
    3. {
    4. Q_UNUSED(widget);
    5. if (dd->control) {
    6. painter->save();
    7. QRectF r = option->exposedRect;
    8. painter->translate(-dd->controlOffset());
    9. r.translate(dd->controlOffset());
    10. dd->control->drawContents(painter, r);
    11. painter->restore();
    12. }
    13.  
    14. if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
    15. qt_graphicsItem_highlightSelected(this, painter, option);
    16. }
    To copy to clipboard, switch view to plain text mode 

    the last two sentences is the Selected state,and delete them.

  6. #6
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to hide the dashed frame outside the QGraphicsItem .

    Did you try setting that flag?
    If yes, what happened?

  7. #7

    Wink Re: How to hide the dashed frame outside the QGraphicsItem .



    look this image from my project ,if I press the circular the right side property tabpage
    show nothing ,because the item don't selecte.

    So this is the matter of set the flag...

    thank you .

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to hide the dashed frame outside the QGraphicsItem .

    before rewriting any Qt-function spend 1 minute on our search engine, because that is a very often asked question! simply remove the QStyle::State_Selected option in your paint method!

Similar Threads

  1. how to hide QgraphicsItem !!!
    By peace_comp in forum Qt Programming
    Replies: 2
    Last Post: 24th May 2008, 09:46
  2. Simple frame control doesn't resize when I hide()
    By MrGarbage in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2007, 22:32

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.