Results 1 to 4 of 4

Thread: QTextEdit and EditEvent

  1. #1
    Join Date
    Apr 2012
    Posts
    40
    Platforms
    Unix/X11 Windows

    Default QTextEdit and EditEvent

    Hi i need help with QTextEdit, i want make smart QTextEdit who know if it was edited (insert, delete some chars), so i want reimplement class QTextEdit and add :
    - bool verbal "isEdited" - its done
    - event who will by know if somting was edit in my QTextEdit

    MyTextEdit
    Qt Code:
    1. #ifndef MYTEXTEDIT_H
    2. #define MYTEXTEDIT_H
    3.  
    4. #include <QtGui>
    5. #include <QtCore>
    6.  
    7. class MyTextEdit : public QTextEdit
    8. {
    9. Q_OBJECT
    10. public:
    11. explicit MyTextEdit(QWidget *parent);
    12.  
    13. private:
    14. bool isEdited;
    15. signals:
    16.  
    17. public slots:
    18.  
    19. protected:
    20.  
    21. };
    22.  
    23. #endif // MYTEXTEDIT_H
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include "mytextedit.h"
    2.  
    3. MyTextEdit::MyTextEdit(QWidget *parent)
    4. {
    5. setParent( parent );
    6. isEdited = false;
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    I try write somting with use KeyEvent but if sombody select and delete or past with the help of mouse then my QTextEdit will by dont konow about this edit.
    Coud you help me with that ??

  2. #2
    Join Date
    Apr 2012
    Posts
    40
    Platforms
    Unix/X11 Windows

    Default Re: QTextEdit and EditEvent

    Srry but i didnt see signal "textChanged()"

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QTextEdit and EditEvent

    This code probably won't work correctly in any case, since you aren't allowing the QTextEdit base class to be properly constructed. Your code should look like this:

    Qt Code:
    1. #include "mytextedit.h"
    2.  
    3. MyTextEdit::MyTextEdit(QWidget *parent)
    4. : QTextEdit( parent )
    5. , isEdited( false )
    6. {
    7. }
    To copy to clipboard, switch view to plain text mode 

    The base class constructor must be called in order to properly construct the entire inheritance hierarchy. There is no need to call setParent() (which you probably did because things weren't working right, I'll bet), because invoking the base class constructor does that already.

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

    Default Re: QTextEdit and EditEvent

    Why not just use QTextDocument::modified?
    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.


Similar Threads

  1. QTextEdit
    By RY in forum Newbie
    Replies: 5
    Last Post: 15th October 2008, 17:52
  2. Replies: 1
    Last Post: 16th February 2007, 07:22
  3. QTextEdit
    By merlvingian in forum Newbie
    Replies: 1
    Last Post: 2nd November 2006, 08:15
  4. QTextEdit Help pls
    By munna in forum Newbie
    Replies: 6
    Last Post: 7th May 2006, 19:18
  5. QTextEdit help pls
    By munna in forum Newbie
    Replies: 2
    Last Post: 29th April 2006, 09:07

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
  •  
Qt is a trademark of The Qt Company.