Results 1 to 1 of 1

Thread: QGraphicsTextItem and paint event

  1. #1
    Join Date
    Sep 2009
    Posts
    49
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QGraphicsTextItem and paint event

    Related To : PyQt 4.6.1
    I am creating a QGraphicsTextItem by sub classing it. The code snippet is take from demo example. The item is working fine.

    1. When I select the text and press delete, nothing happens, It's because in my QMainWindow there is an action with short cut:
    Qt Code:
    1. action.setShortcut(QtGui.QKeySequence.Delete)
    To copy to clipboard, switch view to plain text mode 
    This action is getting triggered. Any pointers to solve this?

    Here is the code:
    Qt Code:
    1. class QxTextItem(QtGui.QGraphicsTextItem):
    2. lostFocus = QtCore.pyqtSignal(QtGui.QGraphicsTextItem)
    3. selectedChange = QtCore.pyqtSignal(QtGui.QGraphicsItem)
    4.  
    5. def __init__(self, parent=None, text=qx.Null):
    6. super(QxTextItem, self).__init__(parent)
    7.  
    8. self.setFlag(QtGui.QGraphicsItem.ItemIsMovable)
    9. self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
    10. self.setHtml(text)
    11.  
    12. def itemChange(self, change, value):
    13. if change == QtGui.QGraphicsItem.ItemSelectedChange:
    14. self.selectedChange.emit(self)
    15. return value
    16.  
    17. def focusOutEvent(self, event):
    18. self.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
    19. self.lostFocus.emit(self)
    20. super(QxTextItem, self).focusOutEvent(event)
    21.  
    22. def mouseDoubleClickEvent(self, event):
    23. if self.textInteractionFlags() == QtCore.Qt.NoTextInteraction:
    24. self.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
    25. super(QxTextItem, self).mouseDoubleClickEvent(event)
    To copy to clipboard, switch view to plain text mode 
    Last edited by prashant; 6th November 2009 at 08:28.
    Prashant


    qt-sdk-win-opensource-2009.03.1.exe
    Python 2.6.3
    PyQt-Py2.6-gpl-4.6-1
    Win XP, 32 Bit

Similar Threads

  1. how to change the line space in QGraphicsTextItem Paint()
    By goldhappywang in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2009, 01:42
  2. QGraphicsTextItem Paint()
    By goldhappywang in forum Qt Programming
    Replies: 5
    Last Post: 18th September 2009, 15:39
  3. QGraphicsTextItem AlphaColor Background to CSS2
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 30th November 2007, 15:17
  4. Problem on set QGraphicsTextItem write protect.
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2007, 20:53
  5. QGraphicsTextItem size
    By Angelo Moriconi in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2007, 08:34

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.