Results 1 to 8 of 8

Thread: Dashed frame around QGraphicsTextItem

  1. #1
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Dashed frame around QGraphicsTextItem

    I have a QGraphisTextItem with Qt::TextBrowserInteraction flag enabled. But when I select text (or any part of the text) there is dashed frame around whole text.

    Does anybody knows how to remove the dashed frame?

    Thanks in advance,
    Toni

  2. #2
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dashed frame around QGraphicsTextItem

    Qt::TextBrowserInteraction is not a flag for graphics item.

    Perhaps, you should specify QGraphicsItem::GraphicsItemFlag or QGraphicsItem::GraphicsItemFlags, as follows.

    textItem->setFlag(QGraphicsItem::ItemIsMovable, true); // item support interactive movement.
    textItem->setFlag(QGraphicsItem::ItemIsSelectable, false); // if flag is true, item supports selection.

    about QGraphicsItem::ItemIsSelectable flag, Qt Reference says
    The item supports selection. Enabling this feature will enable setSelected() to
    toggle selection for the item. It will also let the item be selected automatically as a
    result of calling QGraphicsScene::setSelectionArea(), by clicking on an item, or by
    using rubber band selection in QGraphicsView.
    I'm sorry in poor English.
    kichi

  3. #3
    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: Dashed frame around QGraphicsTextItem

    I have missed that question! It was several times asked here. Simply remove the QStyle::State_Selected option in the paint method of your item!

  4. #4
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dashed frame around QGraphicsTextItem

    Something like:

    Qt Code:
    1. void StatusTextItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
    2. {
    3. QStyleOptionGraphicsItem *o = const_cast<QStyleOptionGraphicsItem*>(option);
    4. o->state &= ~QStyle::State_Selected;
    5. QGraphicsTextItem::paint(painter, o, widget);
    6. }
    To copy to clipboard, switch view to plain text mode 

    It doesn't work, at least on Qt 4.6 RC1. I have not tested with Qt 4.5.3. I don't know if it's bug.

  5. #5
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dashed frame around QGraphicsTextItem

    Something like:

    Qt Code:
    1. void StatusTextItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
    2. {
    3. QStyleOptionGraphicsItem *o = const_cast<QStyleOptionGraphicsItem*>(option);
    4. o->state &= ~QStyle::State_Selected;
    5. QGraphicsTextItem::paint(painter, o, widget);
    6. }
    To copy to clipboard, switch view to plain text mode 

    It doesn't work, at least on Qt 4.6 RC1. I have not tested with Qt 4.5.3. I don't know if it's bug.

  6. #6
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dashed frame around QGraphicsTextItem

    Something like:

    Qt Code:
    1. void StatusTextItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
    2. {
    3. QStyleOptionGraphicsItem *o = const_cast<QStyleOptionGraphicsItem*>(option);
    4. o->state &= ~QStyle::State_Selected;
    5. QGraphicsTextItem::paint(painter, o, widget);
    6. }
    To copy to clipboard, switch view to plain text mode 

    It doesn't work, at least on Qt 4.6 RC1. I have not tested with Qt 4.5.3. I don't know if it's bug.

  7. #7
    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: Dashed frame around QGraphicsTextItem

    Ehm, for your case it's QStyle::State_HasFocus

  8. #8
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Dashed frame around QGraphicsTextItem

    Quote Originally Posted by Lykurg View Post
    Ehm, for your case it's QStyle::State_HasFocus
    Both: State_Selected and State_HasFocus. I have looked into the Qt 4.6 source code

    Problem fixed.

Similar Threads

  1. Retrieval of frame rate in Phonon.
    By Theo Adams in forum Qt Programming
    Replies: 2
    Last Post: 6th July 2010, 19:00
  2. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  3. How to hide the dashed frame outside the QGraphicsItem .
    By robertkun in forum Qt Programming
    Replies: 7
    Last Post: 7th August 2009, 17:06
  4. Replies: 16
    Last Post: 7th March 2006, 15:57
  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.