Results 1 to 5 of 5

Thread: QPlainTextEdit

  1. #1
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QPlainTextEdit

    1) How can I change the mouse cursor when the cursor hovers over a selection?

    2) If I press the right mouse button, a context menu is displayed. How can I make that context menu different based on the position of the mouse cursor over selection or not?

    Thank you

  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: QPlainTextEdit

    Quote Originally Posted by Carlsberg View Post
    2) If I press the right mouse button, a context menu is displayed. How can I make that context menu different based on the position of the mouse cursor over selection or not?
    Set contextMenuPolicy to Qt::CustomContextMenu and use the signal QWidget::customContextMenuRequested(). In the slot query your variables/parameters and build your own menu.

  3. #3
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPlainTextEdit

    Ok, but in customContextMenuRequested() how can I check if the menu was requested while the cursor was on the selection or not. Is there a function that tells me if the selection contains a point (the mouse coordinate) or should I make a series of calculations to find that?

  4. #4
    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: QPlainTextEdit

    Quote Originally Posted by Carlsberg View Post
    how can I check if the menu was requested while the cursor was on the selection or not.
    Not tested, but QTextEdit::cursorForPosition() and QTextCursor::hasSelection() may help you.

  5. The following user says thank you to Lykurg for this useful post:

    Carlsberg (13th June 2009)

  6. #5
    Join Date
    May 2009
    Posts
    52
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPlainTextEdit

    Thank you, I'm pretty sure they'll do the trick

Similar Threads

  1. How to change some colors in a QPlainTextEdit
    By aarelovich in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2009, 23:18
  2. QPlainTextEdit reload text
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 25th April 2009, 14:24
  3. Replies: 1
    Last Post: 14th September 2008, 23:05
  4. Continously Scroll QPlainTextEdit
    By GimpMaster in forum Newbie
    Replies: 2
    Last Post: 12th September 2008, 17:35
  5. QPlainTextEdit scrolling
    By roxton in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 16:55

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.