Mac qplaintextedit navigation keys

  • Hi,

    Is there anyway to make a QPlainTextEdit on the Mac use 'windows keys' for navigation, the way qtcreator does?

    For example, I currently have to use ctrl-a/ctrl-e to go to start/end of line on the Mac. I would prefer to be able to use home/end as on pc/qtcreator. Ditto for top of document, end of document etc.

    I'm using qt4.8


  • The only way I can think of implementing this would be to subclass QPlainTextEdit and override the keypress events.

    You can monitor for specific keys or key combinations and then use QApplication::postEvent() when you find something you want to use. All events captured in the derived class should be passed back to the base class otherwise it won't work as a text editor.

    I am not sure if this is a good idea. You shouldn't use 'windows keys' on a Mac or, for that matter, OS X short cuts in Windows. OS X has it's own key shortcuts that can be used or changed if you don't like them; if your program creates it's own shortcut keys it will add confusion.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.