View Full Version : QPlainTextEdit
Carlsberg
12th June 2009, 08:36
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 :)
Lykurg
12th June 2009, 10:47
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.
Carlsberg
12th June 2009, 12:08
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?
Lykurg
12th June 2009, 12:40
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.
Carlsberg
13th June 2009, 06:12
Thank you, I'm pretty sure they'll do the trick :)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.