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. Is it a bug with QTextEdit?
Forum Updated to NodeBB v4.3 + New Features

Is it a bug with QTextEdit?

Scheduled Pinned Locked Moved General and Desktop
14 Posts 3 Posters 7.4k 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.
  • S Offline
    S Offline
    secretNinja
    wrote on last edited by
    #2

    I don't quite understand your question but it is working correctly in my opinion.

    You are using "QTextOption::WordWrap":http://doc.qt.nokia.com/latest/qtextoption.html#WrapMode-enum and setting it with: @te->setWordWrapMode(QTextOption::WordWrap);@ , aren't you?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      testbugs
      wrote on last edited by
      #3

      Thanks for your reply! May be a picture can be more clearly。

      !http://www.0ttx.com/error.jpg(a picture illustrate the problem)!

      below is my code in a new project, and there is nothing else.
      @
      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      QTextEdit *te = new QTextEdit();
      te->setWordWrapMode(QTextOption::WordWrap); // seems not affect the result
      te->setText(QString(" A"));
      te->show();
      return a.exec();
      }
      @

      1 Reply Last reply
      0
      • S Offline
        S Offline
        secretNinja
        wrote on last edited by
        #4

        QTextOption::WordWrap is doing what it is supposed to do:

        bq. Text is wrapped at word boundaries.

        If you want to add blank space at the beginning of a line you could use "NoWrap" or "ManualWrap".

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #5

          testbugs, did u try to resize the window? :) the A should come back to the first line.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            secretNinja
            wrote on last edited by
            #6

            No, it is staying on the second line ... after resizing the window :)

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #7

              You might want to try using QTextEdit::setPlainText instead of setText. The latter version tries to make a guess what kind of text it is dealing with (rich text or plain text).

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #8

                [quote author="secretNinja" date="1303641377"]No, it is staying on the second line ... after resizing the window :)[/quote]

                I tried your exact code and works fine for me though ...

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  secretNinja
                  wrote on last edited by
                  #9

                  I've made two copies (the code is testbugs's ;) ) and just resize the second one ... "A" goes to the second line (as it is supposed to do according to the documentation ... or at least I understand it that way).

                  !http://img822.imageshack.us/img822/7977/resizer.png(resize)!

                  1 Reply Last reply
                  0
                  • ? This user is from outside of this forum
                    ? This user is from outside of this forum
                    Guest
                    wrote on last edited by
                    #10

                    I confirm the same behavior secretNinja :)

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      testbugs
                      wrote on last edited by
                      #11

                      the problem is when "A" goes to the second line, the blank spaces before "A" disappeared. If i want to input two lines of blank spaces, what should i do in a wordwrap mode? Must I use ManualWrap to implement this myself?

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        testbugs
                        wrote on last edited by
                        #12

                        [quote author="chetankjain" date="1303641793"][quote author="secretNinja" date="1303641377"]No, it is staying on the second line ... after resizing the window :)[/quote]

                        I tried your exact code and works fine for me though ...[/quote]

                        Input more blank spaces before "A" until it goes to the sencond line, and then you will find you can not input any more blank spaces.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          secretNinja
                          wrote on last edited by
                          #13

                          Pressing "Enter" two time do the work. Could two new lines be used instead of two lines of spaces in what you want to do?

                          1 Reply Last reply
                          0
                          • T Offline
                            T Offline
                            testbugs
                            wrote on last edited by
                            #14

                            [quote author="secretNinja" date="1303643751"]Pressing "Enter" two time do the work. Could two new lines be used instead of two lines of spaces in what you want to do?[/quote]

                            I think it is different.

                            I will try if I can implement this by using ManualWrap, Thanks everybody!

                            1 Reply Last reply
                            0

                            • Login

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