Results 1 to 1 of 1

Thread: MoveAnchor problem

  1. #1
    Join Date
    Dec 2014
    Posts
    29
    Thanks
    12
    Qt products
    Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default MoveAnchor problem

    Hello, I'm trying to "paint" everything between /* and */, with this code:

    Qt Code:
    1. self.plainTextEdit.moveCursor(self.plainTextEdit.find("/*"),QtGui.QTextCursor.MoveAnchor)
    2. self.plainTextEdit.moveCursor(self.plainTextEdit.find("*/") ,QtGui.QTextCursor.KeepAnchor)
    3.  
    4.  
    5. cursor = self.plainTextEdit.textCursor()
    6. currentWord = QtWidgets.QTextEdit.ExtraSelection()
    7. yellowColor = QtGui.QColor("yellow")
    8. currentWord.format.setForeground(yellowColor)
    9. currentWord.cursor = cursor
    10.  
    11. extraSelections.append(currentWord)
    To copy to clipboard, switch view to plain text mode 
    But I get this: http://i.imgur.com/ObSvmj5.png

    it seems for some reason, MoveAnchor is not moving to /* location, but from start, can someone explain how can this be fixed?
    Last edited by vuletic; 28th March 2015 at 15: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.