Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML MaximumBlockCount on TextArea
Qt 6.11 is out! See what's new in the release blog

QML MaximumBlockCount on TextArea

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
10 Posts 3 Posters 4.0k Views
  • 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.
  • T Offline
    T Offline
    tuukkap
    wrote on last edited by
    #1

    Hi,

    I've linked below a discussion about maximum line count for textarea. Unfortunately I'm not able to define it for the TextArea. I'm not sure has something changed in the previous 2 years which makes it impossible to use maximumblockcount for TextArea nowadays or is it just that I don't understand something fundamental here? Could someone provide a simple example how it is meant to be defined?

    Thanks in advance,
    Tuukka

    Re: QML TextArea maximum line count

    JonBJ 1 Reply Last reply
    0
    • T tuukkap

      Hi,

      I've linked below a discussion about maximum line count for textarea. Unfortunately I'm not able to define it for the TextArea. I'm not sure has something changed in the previous 2 years which makes it impossible to use maximumblockcount for TextArea nowadays or is it just that I don't understand something fundamental here? Could someone provide a simple example how it is meant to be defined?

      Thanks in advance,
      Tuukka

      Re: QML TextArea maximum line count

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @tuukkap
      I presume this means you are using QtQuick.Controls 1.5 and not QtQuickControls 2.0 ?

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

        @JonB
        I'm using QtQuick.Controls 2.3 but it might be that my issue might be that I don't understand what this sentence means:
        "TextEdit should simply expose the maximum line count"

        JonBJ 1 Reply Last reply
        0
        • T tuukkap

          @JonB
          I'm using QtQuick.Controls 2.3 but it might be that my issue might be that I don't understand what this sentence means:
          "TextEdit should simply expose the maximum line count"

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @tuukkap
          I'm just quoting from your linked post:

          When I switched from QtQuick.Controls 1.5 to QtQuickControls 2.0 the above issue was resolved and setting the maximumBlockCount of the underlying QTextDocument behaves as expected.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tuukkap
            wrote on last edited by
            #5

            @JonB
            I have tried with different QtQuick.Controls versions and I can't get this to work with any of those which probably means that I'm doing something incorrect.

            JonBJ 1 Reply Last reply
            0
            • T tuukkap

              @JonB
              I have tried with different QtQuick.Controls versions and I can't get this to work with any of those which probably means that I'm doing something incorrect.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @tuukkap
              Given that thread says code should now work at QC 2.x, I think you'd best produce a small example of your code problem and post here, for others to comment on.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tuukkap
                wrote on last edited by tuukkap
                #7

                @JonB
                I somehow imagined it should be usable "simply" like below but MaximumBlockCount can't be used from textDocument at least like this:

                        TextArea {
                            id: ticketTextArea
                            textDocument.MaximumBlockCount: 3
                            Layout.preferredHeight: 150
                            Layout.fillWidth: true
                            Layout.maximumHeight: 200
                            Layout.rowSpan: 3
                        }
                

                Thanks for your patience :)

                JonBJ 1 Reply Last reply
                0
                • T tuukkap

                  @JonB
                  I somehow imagined it should be usable "simply" like below but MaximumBlockCount can't be used from textDocument at least like this:

                          TextArea {
                              id: ticketTextArea
                              textDocument.MaximumBlockCount: 3
                              Layout.preferredHeight: 150
                              Layout.fillWidth: true
                              Layout.maximumHeight: 200
                              Layout.rowSpan: 3
                          }
                  

                  Thanks for your patience :)

                  JonBJ Online
                  JonBJ Online
                  JonB
                  wrote on last edited by
                  #8

                  @tuukkap
                  I've never done QML, so I'll have to leave an expert to help you further...

                  BTW, textDocument.MaximumBlockCount --- is QML case-sensitive? Property name is maximumBlockCount.

                  T 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @tuukkap
                    I've never done QML, so I'll have to leave an expert to help you further...

                    BTW, textDocument.MaximumBlockCount --- is QML case-sensitive? Property name is maximumBlockCount.

                    T Offline
                    T Offline
                    tuukkap
                    wrote on last edited by
                    #9

                    @JonB
                    Thanks for your help! Yeah, that starting capital "M" was mistake as I recreated the example but it doesn't work with "m" either.

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      Zhou_1205
                      wrote on last edited by
                      #10
                      const QQuickItem *rootObject = m_logWidget->rootObject();
                      m_logTextArea = rootObject->findChild<QObject *>("logTextArea");
                      const auto *quickTextDocument = qvariant_cast<QQuickTextDocument *>(m_logTextArea->property("textDocument"));
                      auto *textDocument = quickTextDocument->textDocument();
                      textDocument->setMaximumBlockCount(10);
                      

                      Setting on C++ side works for me.

                      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