Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiline text input
Forum Updated to NodeBB v4.3 + New Features

Multiline text input

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 5.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    netherby
    wrote on 27 Feb 2015, 09:22 last edited by
    #1

    So as far as I can see QTextEdit is the only way to do a multiline input box?

    But I'm having two issues with using it in this context. I set it up with both scroll bars always disabled and tab to change focus, also disallowing rich text:
    @setAcceptRichText(false);
    setTabChangesFocus(true);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);@

    The first major problem here is that when you start entering text beyond the bounds of the widget it emits the 'alert' sound for every character entered. I assume this has something to do with the scroll bars being off, but how do you prevent it?

    The second issue is the lack of a way to limit the character input. I can truncate the string on the focusOut event, or mess around with keyPressed or textChanged.. Is there a 'best' way to manage it?

    Really all I want is a QLineEdit which can hold multiple lines and trying to make QTextEdit behave that way.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on 27 Feb 2015, 14:57 last edited by
      #2

      I ran a test using QPlainTextEdit (probably a better choice then QTextEdit in this case).

      I disabled the scroll bars. For the two tests I ran the option to wrap text was left at the default and also set to no wrap.

      I didn't see the alert problem you describe. There was no alert sound created or any other indication of a problem. I made sure to enter text beyond what the control could display.

      With word wrap enabled the text is automatically shuffled to the next line. The control scrolled vertically when more text was entered than could be handled (no scroll bars appeared).

      Without wrap the text continues to the right until a CR is entered. No scroll bar appeared but the control scrolled the contents to show the last entered characters.

      Maybe you have this control sub classed in some way or there is some other option set causing the alerts?

      For limiting text input you can't do it the same way you could with a QLineEdit. At some point you do read the text from the control so it could be done here.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        netherby
        wrote on 28 Feb 2015, 18:21 last edited by
        #3

        I tested using QPlainTextEdit in place of QTextEdit and it works as you describe. So seems to be something that QTextEdit does...

        1 Reply Last reply
        0

        1/3

        27 Feb 2015, 09:22

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved