QTextEdit and LineFeeds

  • I'm currently developing an application that has to evaluate a specific QR-Code under linux.
    I'm using a QTextEdit as input widget. The QR-Code consits of serveal lines and it is scanned by a 2D Barcode Scanner. The lines of the QR-Code are separated by a LineFeed (0x0A) character.

    When I read this QR-Code under Emacs or vi, the code appears as expected.(multiple lines), e.g.:

    When I read the code into a QTextEdit widget, the line breaks disappear (only one long line). e.g.:

    I have tested several properties (setAcceptRichText([true, false], setWordWrapMode, setAutoFormatting)) without success.

    Reconfiguring the Scanner or changing the QR-Code is not an option.

    Is there a change to get all lines from the QR-Code into the QTextEdit widget?
    Any suggestions?

    Thanks in advance,

  • Moderators

    try QPlainTextEdit widget

  • I have tested /examples/mainwindows/application, which contains a QPlainTextEdit widget, without success ...

  • Lifetime Qt Champion


    If you get the QR code in one string you could replace the line feed with carriage return and then set that to your QTextEdit.

    Hope it helps

  • A barcode scanner acts like a Human Interface Device. It sends all keys to to the current active application window. Did you mean to subclass the QTextEdit and override the keyPressEvent(QKeyEvent *e) ?

  • Lifetime Qt Champion

    That would be a good idea to try, yes

Log in to reply

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