Results 1 to 3 of 3

Thread: How can I make the cursor flash?

  1. #1
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default How can I make the cursor flash?

    I paint a cursor in my textedit ,but it not flash,how can i make the cursor flash?


    Qt Code:
    1. void MYTextEdit:: paintEvent(QPaintEvent *event)
    2. {
    3. QPainter p(viewport());
    4. QTextLayout textLayout(document()->toPlainText());
    5. QPointF t(100,100);
    6.  
    7. int leading = fm.leading();
    8. int height = 0;
    9. qreal widthUsed = 0;
    10. textLayout.beginLayout();
    11. while (1) {
    12. QTextLine line = textLayout.createLine();
    13. if (!line.isValid())
    14. break;
    15.  
    16. line.setLineWidth(200);
    17. height += leading;
    18. line.setPosition(QPoint(0, height));
    19. height += (int) line.height();
    20. widthUsed = qMax(widthUsed, line.naturalTextWidth());
    21. textLayout.drawCursor(&p,t,2,3);
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 31st December 2007 at 05:31. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How can I make the cursor flash?

    You'd have to run a timer to turn the cursor on and off. Anyways, have you noticed upcoming QPlainTextEdit?
    Last edited by jpn; 31st December 2007 at 10:53. Reason: spelling error
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    cslijy (31st December 2007)

  4. #3
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can I make the cursor flash?

    Quote Originally Posted by jpn View Post
    You'd have to run a timer to turn the cursor on and off. Anyways, have you noticed upcoming QPlainTextEdit?
    sweet

    Now my code contains these ugly lines:
    Qt Code:
    1. #if QT_VERSION >= 0x040400
    2. # define QTextEditorControl QPlainTextEdit
    3. # warning "Using QPlainTextEdit as the text editor control"
    4. #else
    5. # define QTextEditorControl QTextEdit
    6. #endif
    To copy to clipboard, switch view to plain text mode 

    (it crashes, but I will figure out whats wrong with it eventually)

Similar Threads

  1. QT4 for kde 4 beta 2 configure problem: make not found
    By marcomangiante in forum Installation and Deployment
    Replies: 1
    Last Post: 5th September 2007, 20:35
  2. Window OS make distclean && qmake && make one line
    By patrik08 in forum General Programming
    Replies: 4
    Last Post: 22nd March 2007, 10:43
  3. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  4. Replies: 3
    Last Post: 19th October 2006, 22:13
  5. Qt4.1.4 make errors.
    By impeteperry in forum Installation and Deployment
    Replies: 11
    Last Post: 1st July 2006, 17:27

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.