Results 1 to 2 of 2

Thread: Redirect key strokes

  1. #1
    Join Date
    Sep 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Lightbulb Redirect key strokes

    Hello
    I'm developing a small CAD and I want to copy an AutoCAD feature.
    More specifically, when the user types something in the drawing area,
    I want it to be redirected to a certain QTextEdit.
    I thought about calling onKeyPress() and onKeyRelease() functions but I'm not
    sure if that's enough and it won't cause any nasty bugs. What do you think?

  2. #2
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Redirect key strokes

    erm, maybe use http://doc.qt.io/qt-4.8/qwidget.html#keyPressEvent (and release) and http://doc.qt.io/qt-4.8/qcoreapplication.html#postEvent to re-direct the event.

    maybe this can be done quicker with event filter, otherwise you could knock up a pretty inefficient signal/slot mechanism whereby the drawing area just emits every char that the user types in it, and you connect it to the text edit for appending.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. How to redirect to a URL in Qt
    By xyz in forum Newbie
    Replies: 8
    Last Post: 30th March 2012, 07:39
  2. Redirect printf and update progressbar
    By rouge in forum Newbie
    Replies: 2
    Last Post: 7th October 2011, 23:06
  3. QSettings Redirect into Database Table
    By ChrisW67 in forum Qt Programming
    Replies: 0
    Last Post: 17th December 2009, 22:51
  4. redirect qDebug() to file
    By sriky27 in forum Qt Programming
    Replies: 9
    Last Post: 17th March 2009, 20:21
  5. Redirect printf to QTextEdit?
    By Randulf in forum Qt Programming
    Replies: 9
    Last Post: 12th October 2006, 14:57

Tags for this Thread

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.