QML MaximumBlockCount on TextArea
-
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 -
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 -
@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" -
@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. -
@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 :)
-
@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 :)
-
@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 ismaximumBlockCount. -
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.