Qt / QML - Choose how many characters to be displayed in a Text item -


i display 2 first characters of word in text item. example, have list of words (french, english, italian) , display (fr, en, it).

if elide text, 3 dots (...) @ end , don't want that.

any ideas ?

thanks in advance

you set clip true need play width.

so think best option implement little function in javascript first 2 letters.

example:

main.qml

import qtquick 2.5 import qtquick.window 2.2 import "myscript.js" myfunctions  window {     visible: true      // need play width     text {         width: 13         text: "french"         clip: true     }      // ok. width not necessary     text {         y: 60         text: myfunctions.substring("french")     }      // don't want behaviour     text {         y: 30         width: 25         text: "french"         elide: text.elideright     } } 

myscript.js

function substring(str) {     return str.substring(0, 2); } 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -