Results 1 to 5 of 5

Thread: QTextDocument - getting last modified QTextFragment objects

  1. #1
    Join Date
    Aug 2008
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextDocument - getting last modified QTextFragment objects

    Hello.

    QTextDocument have functions:
    Qt Code:
    1. void QTextDocument::modificationChanged ( bool changed ) [signal]
    2. bool isModified () const
    3. void setModified ( bool m = true )
    To copy to clipboard, switch view to plain text mode 
    Is any way to get last modified QTextFragment objects?
    Last edited by lukass; 30th October 2010 at 17:41. Reason: updated contents: object -> objects

  2. #2
    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: QTextDocument - getting last modified QTextFragment objects

    Right now I don't know such a function, but (as for user changes) the cursor is on the last changed fragment. So may be that is enough for you.

  3. #3
    Join Date
    Aug 2008
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextDocument - getting last modified QTextFragment objects

    Quote Originally Posted by Lykurg View Post
    Right now I don't know such a function, but (as for user changes) the cursor is on the last changed fragment. So may be that is enough for you.
    Probably not.

    I wont this:
    example 1:
    1) user have empty QTextDocument object, so object_ptr->isModified() returns false,
    2) user added some rich text, so object_ptr->isModified() returns true,
    3) user clicked 'add image' icon and afterwards application execute object_ptr->setModified(false),
    4) in this moment I wont get QTextFragment or QTextBlock objects which contains 'some rich text' added by user in point 2.

    example 2:
    1) user have QTextDocument object which contains some rich text with images and object_ptr->isModified() returns false,
    2) user deleted(by normal edit) some rich text with images, so object_ptr->isModified() returns true,
    3) user clicked 'add image' icon and afterwards application execute object_ptr->setModified(false),
    4) in this moment I wont get QTextFragment or QTextBlock objects which contains 'some rich text with images' deleted by user in point 2.

    I think one of solutions is cloning QTextDocument in point 1 and comparing with current QTextDocument in point 4. But this solution is too hangry of memory and CPU time.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTextDocument - getting last modified QTextFragment objects

    There is a QTextDocument::contentsChange() signal which is all you need.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2008
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTextDocument - getting last modified QTextFragment objects

    Quote Originally Posted by wysota View Post
    There is a QTextDocument::contentsChange() signal which is all you need.
    Qt Code:
    1. void QTextDocument::contentsChange ( int position, int charsRemoved, int charsAdded ) [signal]
    To copy to clipboard, switch view to plain text mode 
    I connected this signal to slot. I can track what is added on demand but how can I get removed QTextFragment objects indicated by position and charsRemoved?

Similar Threads

  1. Replies: 1
    Last Post: 20th February 2010, 10:28
  2. URL last modified
    By tsd-charlie in forum Qt Programming
    Replies: 1
    Last Post: 2nd October 2009, 15:09
  3. Modified TextFinder example
    By LoomVortex in forum Newbie
    Replies: 4
    Last Post: 26th August 2009, 11:17
  4. modified files
    By Raajesh in forum Qt Programming
    Replies: 1
    Last Post: 20th May 2008, 13:17
  5. Modified tableview
    By dkite in forum Qt Programming
    Replies: 2
    Last Post: 14th March 2006, 01:58

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.