Results 1 to 5 of 5

Thread: Frame around a QGraphicTextItem

  1. #1
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Frame around a QGraphicTextItem

    Hello,

    I try to program a QGraphicsTextItem, that acts like an editor. Therefore I need a permanent blinking text cursor. For making the QGraphicsTextItem to act like an editor, I use:

    Qt Code:
    1. m_textItem->setTextInteractionFlags(Qt::TextEditorInteraction)
    To copy to clipboard, switch view to plain text mode 

    Here's the problem:
    if this text item is active, there is always a dashed box around it. How can I prevent this box from being shown?

    Thanks a lot

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Frame around a QGraphicTextItem

    Remove the ItemIsSelectable flag, but then it won't receive any focus.

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Frame around a QGraphicTextItem

    Quote Originally Posted by marcel View Post
    Remove the ItemIsSelectable flag, but then it won't receive any focus.
    Thanks, but the problem is the blinking cursor...if I remove the focus, the cursor disappears.

  4. #4
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Frame around a QGraphicTextItem

    This topic is discussed before.
    Anyway answer in short is to derive your own text item and reimplement paint event like this
    Qt Code:
    1. void MyTextItem::paint(QPainter *p, const QStyleOptionGraphicsItem *co, QWidget *w)
    2. {
    3. QStyleOptionGraphicsItem *o = const_cast<QStyleOptionGraphicsItem*>(co);
    4. o->state &= ~QStyle::State_Selected;
    5. QGraphicsTextItem::paint(p,o,w);
    6. }
    To copy to clipboard, switch view to plain text mode 
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  5. The following user says thank you to Gopala Krishna for this useful post:

    Orphelic (23rd August 2007)

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

    Default Re: Frame around a QGraphicTextItem

    I meet a similar problem with QGraphicsItem : there's always a dashed box around my QGraphicsSvgItem whether it's selected or not.
    Who can tell me why?

Similar Threads

  1. How to conrol frame of widgets in a QStatuBar?
    By high_flyer in forum Qt Programming
    Replies: 12
    Last Post: 30th September 2008, 01:19
  2. Display the camera frame in real time
    By alex_lue in forum Qt Programming
    Replies: 8
    Last Post: 27th July 2007, 10:31
  3. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  4. Replies: 7
    Last Post: 28th January 2007, 11:07
  5. Multi frame management ... is it possible ?
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 25th January 2006, 10:41

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.