A
A
Anton2015-12-28 08:25:14
Qt
Anton, 2015-12-28 08:25:14

How to implement line break in QML?

Hello!
There is a ListView, which, at times, contains long titles and texts. It is necessary to somehow limit each element of the list, wrapping lines:
59c2aba0d16b4943b8065360487e181e.png
Now I have this:

ListView {
    id: topPlayersList

    width: 400
    height: 600

    model: newsSqlModel
    delegate: newsListDelegate
}

Component {
   id: newsListDelegate
   Item {
       width: 400
       height: 70

       Row {
           width: 400
           Column {
               width: 300
               Text {
                   text: '<b>Title:</b> ' + title
                   wrapMode: Text.WordWrap
               }
               Text {
                   text: '<b>Text:</b> ' + full_text
                   wrapMode: Text.WordWrap
               }
           }
           Column {
               width: 100
               Button {
                   text: "Del"
                   onClicked: {
                       mainWindow.deleteNews(id)
                   }
               }
               Button {
                   text: "Edit"
                   onClicked: {
                       mainWindow.editNews(id)
                   }
               }
           }
       }
   }
}

But most likely this is the wrong option, since nothing is limited to it ...
Help, please.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jacob E, 2015-12-28
@Zifix

Set text to a fixed width.

R
RareScrap, 2016-04-21
@RareScrap

In my case fixed width didn't help. It was also necessary to define "clip: true" on the parent element

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question