I have a label (shown below) that can display fully qualified file names (including full path).
import QtQml.Models 2.2
import QtQuick.Window 2.2
import QtQuick 2.2
import QtQuick.Controls 1.3
import QtQuick.Controls 2.2 as M2
import QtQuick.Layouts 1.3
ApplicationWindow {
Label {
id: lblSelectedFileId
text: selectedFile
anchors.verticalCenter: parent.verticalCenter
}
}
These file names came become too long to display properly. I would like to accomplish two things:
Learn how to use Text.ElideMiddle to shorten my text.
Learn how to limit the max width of my Label.
I'm sure there is a readily available answer in the documents if I could understand it. Have checked a number of references including these listed below and I still cannot resolve my issues in Python.
- Text QML Type | Qt Quick 5.9 https://doc-snapshots.qt.io/qt5-5.9/qml-qtquick-text.html#elide-prop
- Elide text in TextField | Qt Forum https://forum.qt.io/topic/92006/elide-text-in-textfield
- “text-overflow” for a QLabel - Stack Overflow “text-overflow” for a QLabel’s text rendering in QT
- Elided Label - Qt Wiki https://wiki.qt.io/Elided_Label